Example #1
0
        //Получаем информацию об измеряемом методе из стека и запускаем таймер
        private MethodInformation GetMethodInformation()
        {
            MethodInformation methodInformation = new MethodInformation();

            //Объект для трасировки стека вызова
            StackTrace stackTrace = new StackTrace();

            //Получаем измеряемый метод, GetFrame(2), т.к. по стеку это 3 вызванный метод
            MethodBase currentMethod = stackTrace.GetFrame(2).GetMethod();

            methodInformation.name      = currentMethod.Name;
            methodInformation.className = currentMethod.DeclaringType.Name;

            //Запускаем таймер метода
            methodInformation.stopwatch.Start();

            return(methodInformation);
        }
Example #2
0
        public void AddMethodNode(MethodInformation methodInformation, int threadID, int depthLevel)
        {
            List <MethodInformation> methodsList;

            //Проверяем, в словаре текуущий поток
            if (threadsMethodList.ContainsKey(threadID))
            {
                //Если есть, то находим список методов, нужного уровня
                methodsList = GetLastMethodNode(threadID, depthLevel);
            }
            else
            {
                methodsList = new List <MethodInformation>();
                threadsMethodList.TryAdd(threadID, methodsList);
            }

            methodsList.Add(methodInformation);
        }