static void Main(string[] args) { Thread thread1 = new Thread(new ThreadStart(Method1)); Thread thread2 = new Thread(new ThreadStart(Method1)); thread1.Start(); thread2.Start(); thread1.Join(); thread2.Join(); serializer = new JSONSerializer(); using (var fs = new FileStream("test.json", FileMode.Create)) using (var sw = new StreamWriter(fs)) { serializer.Serialize(sw, tracer.GetTraceResult()); } serializer.Serialize(Console.Out, tracer.GetTraceResult()); Console.WriteLine(); serializer = new XMLSerializer(); using (var fs = new FileStream("test.xml", FileMode.Create)) using (var sw = new StreamWriter(fs)) { serializer.Serialize(sw, tracer.GetTraceResult()); } serializer.Serialize(Console.Out, tracer.GetTraceResult()); Console.ReadKey(); }
public void TestSingleMethod() { SingleMethod(); TraceResult traceResult = tracer.GetTraceResult(); Assert.AreEqual(nameof(SingleMethod), traceResult.Threads[0].Methods[0].MethodName); Assert.AreEqual(nameof(TimeTracerTest), traceResult.Threads[0].Methods[0].ClassName); Assert.AreEqual(0, traceResult.Threads[0].Methods[0].Methods.Count); Assert.IsTrue(traceResult.Threads[0].Methods[0].ElapsedTime >= SLEEP_TIME); }