12 private readonly Dictionary<string, long> sumTicks =
new Dictionary<string, long>();
13 private readonly SortedDictionary<long, ChunkedList<ProfilerEvent>> timeline =
new SortedDictionary<long, ChunkedList<ProfilerEvent>>();
16 private readonly
object synchObj =
new object();
17 private long startTick = 0;
18 private long lastTick = 0;
19 private string lastName =
null;
40 this.CheckNameLocked(Tick);
42 this.AddLocked(Tick,
Event);
51 this.timeline[Tick] = Events;
57 private void CheckNameLocked(
long Tick)
59 if (!
string.IsNullOrEmpty(this.lastName))
61 long Diff = Tick - this.lastTick;
63 if (this.sumTicks.TryGetValue(
this.lastName, out
long l))
64 this.sumTicks[this.lastName] = l + Diff;
67 this.sumTicks[this.lastName] = Diff;
68 this.order.Add(this.lastName);
95 this.CheckNameLocked(Tick);
110 this.CheckNameLocked(Tick);
111 this.lastTick = Tick;
112 this.lastName =
Event.State;
124 long Tick = this.startTick;
126 foreach (
string Name
in this.order)
128 if (this.sumTicks.TryGetValue(Name, out
long Ticks))
130 this.AddLocked(Tick,
new NewState(Tick, Name, this.thread));
135 this.AddLocked(Tick,
new Idle(Tick, this.thread));
A chunked list is a linked list of chunks of objects of type T .
void AddRange(IEnumerable< T > Collection)
Adds a range of elements (last) to the list.
Abstract base class for profiler events.
void Sum(NewState Event)
Sums time for a given state.
void Idle(Idle Event)
Reports thread to be idle.
void Report(ChunkedList< ProfilerEvent > Result)
Reports accumulated events to a list of events.
void Start(Start Event)
Adds an event, as-is.
Accumulator(ProfilerThread Thread)
Accumulates events
void AddAsIs(ProfilerEvent Event)
Adds an event, as-is.
Class that keeps track of events and timing for one thread.