Пример #1
0
        public void InnerMethodTest()
        {
            // checks time, amount, classnames and methodnames
            _tracer.StartTrace();
            Thread.Sleep(_waitTime);
            SingleThreadedMethod();
            _tracer.StopTrace();
            TraceResult traceResult = _tracer.GetTraceResult();

            ThreadTracerResult[] threadTracerResults = new ThreadTracerResult[traceResult.ThreadTracerResults.Count];
            traceResult.ThreadTracerResults.Values.CopyTo(threadTracerResults, 0);

            Assert.AreEqual(1, traceResult.ThreadTracerResults.Count);
            MethodTracerResult extremeMt = threadTracerResults[0].ExtremeMethodResults[0];

            Assert.AreEqual(nameof(TestTracer), extremeMt.ClassName);
            Assert.AreEqual(nameof(InnerMethodTest), extremeMt.MethodName);
            TestIsGreater(extremeMt.ElapsedTime.Milliseconds, _waitTime * 2);
            Assert.AreEqual(1, extremeMt.Inner.Count);
            MethodTracerResult internalMt = extremeMt.Inner[0];

            Assert.AreEqual(nameof(TestTracer), internalMt.ClassName);
            Assert.AreEqual(nameof(SingleThreadedMethod), internalMt.MethodName);
            TestIsGreater(internalMt.ElapsedTime.Milliseconds, _waitTime);
        }
Пример #2
0
        private XElement Save(MethodTracerResult methodTracer)
        {
            var savedTracedMetod = new XElement("method",
                                                new XAttribute("name", methodTracer.MethodName),
                                                new XAttribute("time", methodTracer.ElapsedTime.Milliseconds + "ms"),
                                                new XAttribute("class", methodTracer.ClassName));

            if (methodTracer.Inner.Any())
            {
                savedTracedMetod.Add(from innerMethod in methodTracer.Inner
                                     select Save(innerMethod));
            }
            return(savedTracedMetod);
        }
Пример #3
0
        private JToken Save(MethodTracerResult methodTracerResult)
        {
            var savedTracedMetod = new JObject
            {
                { "name", methodTracerResult.MethodName },
                { "class", methodTracerResult.ClassName },
                { "time", methodTracerResult.ElapsedTime.Milliseconds + "ms" }
            };

            if (methodTracerResult.Inner.Any())
            {
                savedTracedMetod.Add("methods", new JArray(from mt in methodTracerResult.Inner
                                                           select Save(mt)));
            }
            return(savedTracedMetod);
        }