public void CrudePerformanceTest() { int count = 10 * 1000 * 1000; double MaxNSPerMessage = 50; var ctx = OpenTap.Diagnostic.LogFactory.CreateContext(); var counter = new CountingListener(); var log = ctx.CreateLog("Test"); ctx.AttachListener(counter); ctx.Async = true; ctx.MessageBufferSize = 0; var sw = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < count; i++) { log.LogEvent(0, "test"); } sw.Stop(); ctx.Flush(); Assert.AreEqual(count, counter.RecvdMessages); Assert.IsTrue(sw.ElapsedTicks * 100.0 / count <= MaxNSPerMessage, "Time to insert messages was {0} ({1} ns/msg)", sw.Elapsed.TotalSeconds, sw.ElapsedTicks * 100.0 / count); }
public void SimpleBufferTest() { var ctx = OpenTap.Diagnostic.LogFactory.CreateContext(); var counter = new CountingListener(); var log = ctx.CreateLog("Test"); ctx.AttachListener(counter); ctx.Async = false; ctx.MessageBufferSize = 1; log.LogEvent(0, "abc"); log.LogEvent(0, "abc{0}", "t"); log.LogEvent(0, 0, "abc"); log.LogEvent(0, 0, "abc{0}", "t"); ctx.Flush(); Assert.AreEqual(4, counter.RecvdMessages); }