public void TestPausingWrapper() { PausingWrapper wrapper = null; wrapper = new PausingWrapper(delegate { Console.WriteLine("Hello"); while (!TW.Graphics.Keyboard.IsKeyPressed(Key.Return)) { wrapper.Pause(); } }, new SimpleThreadFactory()); engine.AddSimulator(new BasicSimulator(wrapper.Execute)); }
public void TestPausingWrapperPerformance() { var numFrames = 1000; var watch = new Stopwatch(); var pausable = new PausingWrapper(simulateDummy, new SimpleThreadFactory()); watch.Reset(); watch.Start(); simulateDummy(); watch.Stop(); var dummyTime = watch.ElapsedMilliseconds; watch.Reset(); watch.Start(); for (int i = 0; i < numFrames; i++) { simulateDummy(); } watch.Stop(); var normalTime = watch.ElapsedMilliseconds; watch.Reset(); watch.Start(); for (int i = 0; i < numFrames; i++) { pausable.Execute(); } watch.Stop(); var pausableTime = watch.ElapsedMilliseconds; Console.WriteLine("Dummy time: {0}", dummyTime); Console.WriteLine("Normal time: {0}", normalTime); Console.WriteLine("Pausable time: {0}", pausableTime); }