public void TestPushPull() { uint loopSize = 10000; Console.WriteLine("Testing pull/push benchmark..., {0} times", loopSize); NetMQMessageBus busAlarm = new NetMQMessageBus(); NetMQMessageBus busEt = new NetMQMessageBus(); busAlarm.Start(Path.Combine(xmlPath, "AlarmService.xml")); busEt.Start(Path.Combine(xmlPath, "EtService.xml")); MsgHandler h2 = new MsgHandler { Received = 0, Name = "H2(ET)" }; long start = DateTime.Now.Ticks; busEt.Pull(h2.OnMessageReceived); new Thread(new MsgPusher { Name = "et", bus = busAlarm, LoopSize = loopSize }.DoWork).Start(); while (h2.Received != loopSize) { Thread.Sleep(10); } double elapsed = (DateTime.Now.Ticks - start) / 10000000.0; //s double speed = loopSize / elapsed; // 15479 Console.WriteLine("DONE, loops = {0},Speed = {1:#0.00} msg/s", h2.Received, speed); busAlarm.Stop(); busEt.Stop(); }
public void TestOpenClose() { NetMQMessageBus busAlarm = new NetMQMessageBus(); NetMQMessageBus busEt = new NetMQMessageBus(); uint loopSize = 10; uint sendloop = 1; Console.WriteLine("Testing start/stop benchmark..., {0} times", loopSize); for (uint i = 0; i < loopSize; i++) { busAlarm.Start(Path.Combine(xmlPath, "AlarmService.xml")); busEt.Start(Path.Combine(xmlPath, "EtService.xml")); MsgHandler h2 = new MsgHandler { Received = 0, Name = "H2(ET)" }; busEt.Pull(h2.OnMessageReceived); new Thread(new MsgPusher { Name = "et", bus = busAlarm, LoopSize = sendloop }.DoWork).Start(); while (h2.Received != sendloop) { Thread.Sleep(10); } busAlarm.Stop(); busEt.Stop(); } Console.WriteLine("Done!"); }