static void CheckEqual(MethodTraceResult expected, MethodTraceResult result)
 {
     Assert.AreEqual(expected.Class, result.Class);
     Assert.AreEqual(expected.Name, result.Name);
     Assert.AreEqual(expected.Methods.Count, result.Methods.Count);
     Assert.IsNotNull(result.Time);
 }
Exemple #2
0
 static void CheckAreEqual(MethodTraceResult expected, MethodTraceResult actual)
 {
     Assert.AreEqual(expected.MethodClassName, actual.MethodClassName);
     Assert.AreEqual(expected.MethodName, actual.MethodName);
     Assert.AreEqual(expected.Methods.Count, actual.Methods.Count);
     Assert.IsNotNull(actual.MethodExecuteTime);
 }
Exemple #3
0
        public void TestComb()
        {
            Comb.Test(tracer);
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods[0];
            var expected = new MethodTraceResult();

            expected.MethodName      = "Test";
            expected.MethodClassName = "Comb";
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods[0].MethodClassName = "TestEZ";
            expected.Methods[0].MethodName      = "Test";
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods[1].MethodClassName = "RecursionTest";
            expected.Methods[1].MethodName      = "Test";
            try
            {
                CheckAreEqual(expected, actual);
                CheckAreEqual(expected.Methods[0], actual.Methods[0]);
                CheckAreEqual(expected.Methods[1], actual.Methods[1]);
                logger.Info(nameof(TestComb) + " - passed");
            }
            catch (Exception e)
            {
                logger.Error(e, nameof(TestComb) + " - failed");
            }
        }
Exemple #4
0
        public void MeasureMutualRecursionCall_int_2_Equal()
        {
            MutualRecursionTest.MutualCall(2, tracer);
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods[0];
            var expected = new MethodTraceResult();

            expected.MethodName      = "MutualCall";
            expected.MethodClassName = "MutualRecursionTest";
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods[0].MethodClassName = "MutualRecursionTest";
            expected.Methods[0].MethodName      = "MutualCall2";
            expected.Methods[0].Methods.Add(new MethodTraceResult());
            expected.Methods[0].Methods[0].MethodName      = "MutualCall";
            expected.Methods[0].Methods[0].MethodClassName = "MutualRecursionTest";
            expected.Methods[0].Methods[0].Methods.Add(new MethodTraceResult());
            expected.Methods[0].Methods[0].Methods[0].MethodName      = "MutualCall2";
            expected.Methods[0].Methods[0].Methods[0].MethodClassName = "MutualRecursionTest";
            expected.Methods[0].Methods[0].Methods[0].Methods.Add(new MethodTraceResult());
            expected.Methods[0].Methods[0].Methods[0].Methods[0].MethodName      = "MutualCall";
            expected.Methods[0].Methods[0].Methods[0].Methods[0].MethodClassName = "MutualRecursionTest";

            try
            {
                CheckAreEqual(expected, actual);
                CheckAreEqual(expected.Methods[0], actual.Methods[0]);
                CheckAreEqual(expected.Methods[0].Methods[0], actual.Methods[0].Methods[0]);
                CheckAreEqual(expected.Methods[0].Methods[0].Methods[0], actual.Methods[0].Methods[0].Methods[0]);
                logger.Info(nameof(MeasureMutualRecursionCall_int_2_Equal) + " - passed");
            }
            catch (Exception e)
            {
                logger.Error(e, nameof(MeasureMutualRecursionCall_int_2_Equal) + " - failed");
            }
        }
        public void MeasureSimpleCall_None_Equal()
        {
            SimpleTest.SimpleCall();
            var actual   = tracer.GetTraceResult().Threads[0].Methods[0];
            var expected = new MethodTraceResult("SimpleTest", "SimpleCall");

            CheckEqual(expected, actual);
        }
Exemple #6
0
 private void SetUp()
 {
     _threadTraceResult = new ThreadTraceResult(ThreadId);
     _methodTraceResult = new MethodTraceResult("class_name", "method_name")
     {
         Duration = Duration
     };
     _threadTraceResult.AddMethodTraceResult(_methodTraceResult);
 }
Exemple #7
0
        public void TestEZMethod()
        {
            TestEZ.Test();
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods[0];
            var expected = new MethodTraceResult();

            expected.MethodName      = "Test";
            expected.MethodClassName = "TestEZ";
            CheckAreEqual(expected, actual);
        }
        public void MeasureNestedCall_None_Equal()
        {
            NestedTest.NestedCall();
            var actual   = tracer.GetTraceResult().Threads[0].Methods[0];
            var expected = new MethodTraceResult("NestedTest", "NestedCall");

            expected.Methods.Add(new MethodTraceResult("SimpleTest", "SimpleCall"));

            CheckEqual(expected, actual);
        }
        public void MeasureThreadCall_None_Equal()
        {
            ThreadTest.CreateNewThread();
            var actual    = tracer.GetTraceResult().Threads;
            var expected  = new MethodTraceResult("ThreadTest", "CreateNewThread");
            var expected1 = new MethodTraceResult("ThreadTest", "NewThreadCall");

            Assert.AreEqual(2, actual.Count);
            CheckEqual(expected, actual[1].Methods[0]);
            CheckEqual(expected1, actual[0].Methods[0]);
        }
        public void MeasureSequentialCall_None_Equal()
        {
            SequentialTest.SequentialCall();
            var actual   = tracer.GetTraceResult().Threads[0].Methods;
            var expected = new MethodTraceResult("SimpleTest", "SimpleCall");

            foreach (MethodTraceResult m in actual)
            {
                CheckEqual(expected, m);
            }
        }
Exemple #11
0
        public void TestRowMethod()
        {
            TestEZ.Test();
            TestEZ.Test();
            TestEZ.Test();
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods.Count;
            var expected = new MethodTraceResult();

            expected.Methods.Add(new MethodTraceResult());
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods.Add(new MethodTraceResult());
            Assert.AreEqual(expected.Methods.Count, actual);
        }
        public void MeasureMutualRecursionCall_int_1_Equal()
        {
            MutualRecursionTest.MutualCall(1);
            var actual   = tracer.GetTraceResult().Threads[0].Methods[0];
            var expected = new MethodTraceResult("MutualRecursionTest", "MutualCall");

            expected.Methods.Add(new MethodTraceResult("MutualRecursionTest", "MutualCall2"));
            expected.Methods[0].Methods.Add(new MethodTraceResult("MutualRecursionTest", "MutualCall"));

            CheckEqual(expected, actual);
            CheckEqual(expected.Methods[0], actual.Methods[0]);
            CheckEqual(expected.Methods[0].Methods[0], actual.Methods[0].Methods[0]);
        }
Exemple #13
0
        public void InsertTestMethod()
        {
            InsertTest.InsertTestMethod();
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods[0];
            var expected = new MethodTraceResult();

            expected.MethodName      = "InsertTestMethod";
            expected.MethodClassName = "InsertTest";
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods[0].MethodClassName = "TestEZ";
            expected.Methods[0].MethodName      = "Test";
            CheckAreEqual(expected, actual);
            CheckAreEqual(expected.Methods[0], actual.Methods[0]);
        }
Exemple #14
0
        public void TestRecMethod()
        {
            RecursionTest.Test(0);
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods[0];
            var expected = new MethodTraceResult();

            expected.MethodName      = "Test";
            expected.MethodClassName = "RecursionTest";
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods[0].MethodClassName = "RecursionTest";
            expected.Methods[0].MethodName      = "Test";
            CheckAreEqual(expected, actual);
            CheckAreEqual(expected.Methods[0], actual.Methods[0]);
        }
Exemple #15
0
        public void TestRowMethod()
        {
            TestEZ.Test(tracer);
            TestEZ.Test(tracer);
            TestEZ.Test(tracer);
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods.Count;
            var expected = new MethodTraceResult();

            expected.Methods.Add(new MethodTraceResult());
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods.Add(new MethodTraceResult());
            try
            {
                Assert.AreEqual(expected.Methods.Count, actual);
                logger.Info(nameof(TestRowMethod) + " - passed");
            }
            catch (Exception e)
            {
                logger.Error(e, nameof(TestRowMethod) + " - failed");
            }
        }
Exemple #16
0
        public void TestEZMethod()
        {
            TestEZ.Test(tracer);
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods[0];
            var expected = new MethodTraceResult();

            expected.MethodName      = "Test";
            expected.MethodClassName = "TestEZ";
            try
            {
                Assert.AreEqual(expected.MethodClassName, actual.MethodClassName);
                Assert.AreEqual(expected.MethodName, actual.MethodName);
                Assert.AreEqual(expected.Methods.Count, actual.Methods.Count);
                Assert.IsNotNull(actual.MethodExecuteTime);
                logger.Info(nameof(TestEZMethod) + " - passed");
            }
            catch (Exception e)
            {
                logger.Error(e, nameof(TestEZMethod) + " - failed");
            }
        }
Exemple #17
0
 public void StartTrace(string className, string methodName)
 {
     if (!_active)
     {
         _active            = true;
         _startTime         = DateTimeOffset.Now.ToUnixTimeMilliseconds();
         _methodTraceResult = new MethodTraceResult(className, methodName);
     }
     else
     {
         MethodTracer innerMethodTracer;
         if (_innerMethodTracers.Count == 0)
         {
             innerMethodTracer = new MethodTracer();
             _innerMethodTracers.Push(innerMethodTracer);
         }
         else
         {
             innerMethodTracer = _innerMethodTracers.Peek();
         }
         innerMethodTracer.StartTrace(className, methodName);
     }
 }
Exemple #18
0
        public void InsertTestMethod()
        {
            InsertTest.InsertTestMethod(tracer);
            var actual   = tracer.GetTraceResult().Theards[Thread.CurrentThread.ManagedThreadId].Methods[0];
            var expected = new MethodTraceResult();

            expected.MethodName      = "InsertTestMethod";
            expected.MethodClassName = "InsertTest";
            expected.Methods.Add(new MethodTraceResult());
            expected.Methods[0].MethodClassName = "TestEZ";
            expected.Methods[0].MethodName      = "Test";

            try
            {
                CheckAreEqual(expected, actual);
                CheckAreEqual(expected.Methods[0], actual.Methods[0]);
                Assert.IsNotNull(actual.Methods[0].MethodExecuteTime);
                logger.Info(nameof(InsertTestMethod) + " - passed");
            }
            catch (Exception e)
            {
                logger.Error(e, nameof(InsertTestMethod) + " - failed");
            }
        }
 private void SetUp()
 {
     _methodTraceResult = new MethodTraceResult(ClassName, MethodName);
 }