public void RunTest() { using (HaywireBridge Sender = new HaywireBridge("PerformanceTest", HaywireStartUpMode.PerformanceTest)) using (HaywireBridge Receiver = new HaywireBridge("PerformanceTest", HaywireStartUpMode.Debug)) { const int loops = 1000000; Stopwatch sw = new Stopwatch(); Sender.RaiseEvent(-1);//warm up sw.Start(); for (int i = 0; i < loops; i++) { Sender.RaiseEvent(i); } sw.Stop(); Assembly assembly = Assembly.LoadFrom("MemoryMapBridgeProxy.dll"); String version = assembly.GetName().Version.ToString(); Console.WriteLine("{0} loops in {1}ms, {2:N0}/sec. -- Version: {3} -- {4:u}", loops, sw.ElapsedMilliseconds, loops * TimeSpan.TicksPerSecond / (1.0 * sw.ElapsedTicks), version, DateTime.Now); Console.ReadLine(); } }
private void LoopableTest(String startingString) { _dataTestbasicHaywire = startingString; const string orignalMessage2 = "Something witless"; using (IHaywireBridge hwOut = new HaywireBridge()) using (IHaywireBridge hwIn = new HaywireBridge()) { Debug.WriteLine("Pre subscribe"); hwOut.SubscribeToEvent(ProcessResponse, MessageType.TestRequest); Thread.Sleep(1); Debug.WriteLine("Pre raise"); hwIn.RaiseEvent(orignalMessage2, MessageType.TestRequest); Debug.WriteLine("Post raise"); } Stopwatch sw = new Stopwatch(); int count = 0; sw.Start(); while (_dataTestbasicHaywire == startingString && count < 1000) { count++; Thread.Sleep(1); //Give the processing thread a chance to complete } sw.Stop(); Debug.WriteLine("Time take to complete {0}ms, count {1}", sw.ElapsedMilliseconds, count); Assert.That(_dataTestbasicHaywire, Is.EqualTo(orignalMessage2), "Send a simple Text message"); }
static void Main(string[] args) { Mutex shutDownSynchMutex = new Mutex(false, "haywireShutDownSyncMutex"); String filename = HaywireBridge.DefaultMemorymappedFileName; HaywireStartUpMode startUpMode = HaywireStartUpMode.Default; if (args.Any()) { filename = args[0]; Enum.TryParse(args[1], true, out startUpMode); } using (HaywireBridge hb1 = new HaywireBridge(filename, startUpMode)) { try { Console.WriteLine("Minion Runner Started running HaywireBridge version {0}", hb1.Version); //Mutex used to close minion app when a parent debug app is closed shutDownSynchMutex.WaitOne(); shutDownSynchMutex.ReleaseMutex(); } catch (AbandonedMutexException) { //swallow Console.WriteLine("Shutting Down"); } } }
public void TestBasicHaywire2() { const string orignalMessage2 = "Something less witty"; using (IHaywireBridge hwOut = new HaywireBridge()) using (IHaywireBridge hwIn = new HaywireBridge()) { hwOut.SubscribeToEvent(ProcessResponse, MessageType.TestRequest); //Thread.Sleep(100); hwIn.RaiseEvent(orignalMessage2, MessageType.TestRequest); } Thread.Sleep(100);//Give the processing thread a chance to complete Assert.That(_dataTestbasicHaywire, Is.EqualTo(orignalMessage2), "Send a simple Text message"); }
private void HaywireThread() { using (HaywireBridge hb1 = new HaywireBridge("coffee")) { int m = 1; while (_stillRunning) { var message = Console.ReadLine(); if (message != null && message.Equals("quit", StringComparison.InvariantCultureIgnoreCase)) { break; } hb1.RaiseEvent(m); m++; } } }
public PerformanceTestCoordinator() { Bridge = new HaywireBridge(FileName, HaywireStartUpMode.PerformanceTest); AggregateCatalog catalog = new AggregateCatalog(); AssemblyCatalog assemblyCatalog = new AssemblyCatalog(typeof(Program).Assembly); // DirectoryCatalog directoryCatalog = new DirectoryCatalog(".", "Library*.dll"); // catalog.Catalogs.Add(directoryCatalog); catalog.Catalogs.Add(assemblyCatalog); this.Container = new CompositionContainer(catalog); //CompositionBatch batch = new CompositionBatch(); //batch.AddExportedValue(this.Container); // this.Container.Compose(batch); this.Container.ComposeParts(this); }