Esempio n. 1
0
 private static void AdjustStartPointForSubtree(ProfileTreeNode node, long reductionMagnitude)
 {
     node.PerformanceLog.StartTimeStamp -= reductionMagnitude;
     if (node.ChildNodes.Any())
     {
         foreach (var childNode in node.ChildNodes)
         {
             AdjustStartPointForSubtree(childNode, reductionMagnitude);
         }
     }
 }
Esempio n. 2
0
        public ProfileContext(string description, bool ensureRoot = false)
        {
            if (!IsProfilingEnabled())
            {
                return;
            }
            if (ensureRoot)
            {
                MacroLogInfos.Value = new Dictionary <string, string>();
            }

            if (ensureRoot && CurrentScopeNode != null)
            {
                throw new InvalidOperationException("Cannot instantiate a root node. Non-null profiling context found.");
            }

            _isRoot = ensureRoot;
            var parentNode = GetPendingUplineNode();

            if (!_isRoot && parentNode == null)
            {
                _skipStatCollection = true;
                return;
            }

            var newScopeNode = new ProfileTreeNode()
            {
                PerformanceLog = new PerformanceLog()
                {
                    Info = description
                },
                ParentNode = parentNode
            };

            if (parentNode != null)
            {
                parentNode.ChildNodes.AddLast(newScopeNode);
            }

            _currentScopeNode.Value = newScopeNode;
            _timer.Start();
        }