Beispiel #1
0
        /// <summary>
        ///     Removes a <see cref="ProfilerFrame" /> from the stack.
        /// </summary>
        /// <param name="frame">The <see cref="ProfilerFrame" /> that should be removed from the stack.</param>
        public static void PopFrame(ProfilerFrame frame)
        {
            lock (SyncObject) {
                _logger?.Invoke($"{new string(' ', Stack.Count * 2 - 2)} {(frame.IsFrameStartLogged ? "<=" : "<>")} {frame.Name}: {frame.Stopwatch.Elapsed.TotalMilliseconds:N6}ms");

                var total = Totals.ContainsKey(frame.Name) ? Totals[frame.Name] : new ProfiledBlock(frame.Scope, frame.Method);
                total.Add(frame);
                Totals[frame.Name] = total;
                Stack.RemoveAt(Stack.Count - 1);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Adds a <see cref="ProfilerFrame" /> to the stack.
        /// </summary>
        /// <param name="frame">The <see cref="ProfilerFrame" /> that should be added to the stack.</param>
        public static void PushFrame(ProfilerFrame frame)
        {
            lock (SyncObject) {
                if (_logger != null)
                {
                    var last = Stack.LastOrDefault();
                    if (last != null && !last.IsFrameStartLogged)
                    {
                        _logger.Invoke($"{new string(' ', Stack.Count * 2 - 2)} => {last.Name}");
                        last.IsFrameStartLogged = true;
                    }
                }

                Stack.Add(frame);
            }
        }