public void Should_be_fast() { Fiber fiber = new ThreadPoolFiber(); const int limit = 5000000; var complete = new Future<int>(); Channel<MsgStruct> channel = new ConsumerChannel<MsgStruct>(fiber, message => { if (message.Count == limit) complete.Complete(limit); }); using (var timer = new FunctionTimer("Throughput", x => { Trace.WriteLine("Time to execute: " + (int) x.ElapsedMilliseconds + "ms"); Trace.WriteLine("Per second throughput: " + (int) (limit/(x.ElapsedMilliseconds/1000))); })) { for (int i = 1; i <= limit; i++) { channel.Send(new MsgStruct { Count = i, Other = i*8, }); } timer.Mark(); complete.WaitUntilCompleted(30.Seconds()).ShouldBeTrue(); } }
public void The_tracker_should_do_its_job() { string header; using (var tracker = new FunctionTimer("TEST", VerifyCalled)) { using (var mark = tracker.Mark()) { } header = tracker.Header; } Assert.AreEqual("Date Time TimeTaken Mark1 Description", header); }