Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Fixed performance test.
Browse files Browse the repository at this point in the history
Changed IncomingMessageEventArgs to directly use the session instead of the super class.
  • Loading branch information
DJGosnell committed Aug 31, 2016
1 parent bd2fcc2 commit 95ec972
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Compile Include="ConsoleCopy.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimpleMqSession.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
12 changes: 6 additions & 6 deletions DtronixMessageQueue.Tests.Performance/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static void WriteSysInfo() {
}

private static void StartClient(int total_loops, int total_messages, int total_frames, int frame_size) {
var cl = new MqClient(new MqSocketConfig() {
var cl = new MqClient<SimpleMqSession>(new MqSocketConfig() {
Ip = "127.0.0.1",
Port = 2828
});
Expand Down Expand Up @@ -150,7 +150,7 @@ private static void StartClient(int total_loops, int total_messages, int total_f
}

private static void StartServer(int total_messages, int total_clients) {
var server = new MqServer(new MqSocketConfig() {
var server = new MqServer<SimpleMqSession>(new MqSocketConfig() {
Ip = "127.0.0.1",
Port = 2828
});
Expand All @@ -163,7 +163,7 @@ private static void StartServer(int total_messages, int total_clients) {
builder.Write("START");
var start_message = builder.ToMessage(true);

ConcurrentDictionary<MqSession, ClientRunInfo> clients_info = new ConcurrentDictionary<MqSession, ClientRunInfo>();
ConcurrentDictionary<SimpleMqSession, ClientRunInfo> clients_info = new ConcurrentDictionary<SimpleMqSession, ClientRunInfo>();


server.Connected += (sender, session) => {
Expand Down Expand Up @@ -206,7 +206,7 @@ private static void StartServer(int total_messages, int total_clients) {

private class ClientRunInfo {
public int Runs { get; set; }
public MqSession Session { get; set; }
public SimpleMqSession Session { get; set; }

}

Expand Down Expand Up @@ -270,7 +270,7 @@ static void InProcessTest() {
}

private static void MqInProcessPerformanceTests(int runs, int loops, MqMessage message, MqSocketConfig config) {
var server = new MqServer(config);
var server = new MqServer<SimpleMqSession>(config);
server.Start();

double[] total_values = { 0, 0, 0 };
Expand All @@ -280,7 +280,7 @@ private static void MqInProcessPerformanceTests(int runs, int loops, MqMessage m
var wait = new AutoResetEvent(false);
var complete_test = new AutoResetEvent(false);

var client = new MqClient(config);
var client = new MqClient<SimpleMqSession>(config);

Console.WriteLine("| Build | Messages | Msg Bytes | Milliseconds | MPS | MBps |");
Console.WriteLine("|---------|------------|-----------|--------------|------------|----------|");
Expand Down
4 changes: 4 additions & 0 deletions DtronixMessageQueue.Tests.Performance/SimpleMqSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace DtronixMessageQueue.Tests.Performance {
public class SimpleMqSession : MqSession<SimpleMqSession> {
}
}
4 changes: 2 additions & 2 deletions DtronixMessageQueue/IncomingMessageEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public class IncomingMessageEventArgs<TSession> : EventArgs
/// <summary>
/// If this message is on the server, this will contain the reference to the connected session of the client.
/// </summary>
public MqSession<TSession> Session { get; }
public TSession Session { get; }

/// <summary>
/// Creates an instance of the event args.
/// </summary>
/// <param name="messages">Messages read and ready to be used.</param>
/// <param name="session">Server session. Null if this is on the client.</param>
public IncomingMessageEventArgs(Queue<MqMessage> messages, MqSession<TSession> session) {
public IncomingMessageEventArgs(Queue<MqMessage> messages, TSession session) {
Messages = messages;
Session = session;
}
Expand Down
2 changes: 1 addition & 1 deletion DtronixMessageQueue/MqSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ internal void ProcessIncomingQueue() {
//Postmaster.SignalReadComplete(this);

if (messages != null) {
OnIncomingMessage(this, new IncomingMessageEventArgs<TSession>(messages, this));
OnIncomingMessage(this, new IncomingMessageEventArgs<TSession>(messages, (TSession)this));
}
}

Expand Down

0 comments on commit 95ec972

Please sign in to comment.