3using System.Globalization;
55 private readonly
string name;
56 private readonly
int order;
57 private readonly
bool sampleDelta;
62 private double lastSample = 0;
63 private long? startedAt =
null;
64 private long? stoppedAt =
null;
75 this.name = this.label =
Name;
92 this.name = this.label =
Name;
96 this.profiler = this.parent.
Profiler;
103 public string Name => this.name;
112 set => this.label = value;
154 this.subThreads.Add(Result);
164 this.events.Add(
new NewState(this.profiler.ElapsedTicks, State,
this));
173 if (this.sampleDelta)
175 Sample += this.lastSample;
176 this.events.Add(
new NewSample(this.profiler.ElapsedTicks, Sample,
this));
177 this.lastSample = Sample;
180 this.events.Add(
new NewSample(this.profiler.ElapsedTicks, Sample,
this));
188 this.events.Add(
new Idle(this.profiler.ElapsedTicks,
this));
215 this.events.Add(
new Interval(this.profiler.GetTicks(From),
this.profiler.GetTicks(To),
Label,
this));
235 this.events.Add(
new Event(this.profiler.ElapsedTicks,
Name,
this));
245 this.events.Add(
new Event(this.profiler.ElapsedTicks,
Name,
Label,
this));
254 this.events.Add(
new Events.Exception(
this.profiler.ElapsedTicks,
Exception,
this));
264 this.events.Add(
new Events.Exception(
this.profiler.ElapsedTicks,
Exception,
Label,
this));
272 long Ticks = this.profiler.ElapsedTicks;
273 this.startedAt = Ticks;
274 this.events.Add(
new Start(Ticks,
this));
282 long Ticks = this.profiler.ElapsedTicks;
283 this.stoppedAt = Ticks;
284 this.events.Add(
new Stop(Ticks,
this));
294 Output.WriteStartElement(
"Thread");
295 Output.WriteAttributeString(
"name", this.name);
296 Output.WriteAttributeString(
"label", this.label);
297 Output.WriteAttributeString(
"type", this.type.ToString());
299 Output.WriteStartElement(
"Events");
309 Output.WriteEndElement();
314 Output.WriteEndElement();
327 Output.Append(
"robust \"");
331 Output.Append(
"binary \"");
336 Output.Append(
"analog \"");
342 Output.Append(
"concise \"");
346 Output.Append(this.label);
347 Output.Append(
"\" as T");
348 Output.AppendLine(this.order.ToString());
372 public string Key =>
"T" + this.order.ToString();
386 if (this.startedAt.HasValue &&
this.stoppedAt.HasValue)
388 StringBuilder Output = States.Summary;
389 long Ticks = this.stoppedAt.Value - this.startedAt.Value;
390 string ElapsedStr = this.profiler.ToTimeStr(Ticks,
this, States.TimeUnit, 3);
391 KeyValuePair<double, string> Time;
393 Output.Append(this.Key);
396 Time = this.profiler.ToTime(this.startedAt.Value,
this, States.TimeUnit);
397 Output.Append(Time.Key.ToString(
"F0", CultureInfo.InvariantCulture));
399 Output.Append(
" <-> @");
401 Time = this.profiler.ToTime(this.stoppedAt.Value,
this, States.TimeUnit);
402 Output.Append(Time.Key.ToString(
"F0", CultureInfo.InvariantCulture));
404 Output.Append(
" : ");
405 Output.AppendLine(ElapsedStr);
417 return this.profiler.ToTime(Ticks,
this,
TimeUnit);
428 return this.profiler.ToTimeStr(Ticks,
this,
TimeUnit, 7);
A chunked list is a linked list of chunks of objects of type T .
override void ExportPlantUml(PlantUmlStates States)
Exports events to PlantUML.
override void ExportPlantUmlPreparation()
Prepares the event for export to PlantUML
Contains a new sample value.
Abstract base class for profiler events.
virtual void Accumulate(Accumulator Accumulator)
Accumulates the event.
virtual void ExportXml(XmlWriter Output, ProfilerEvent Previous, TimeUnit TimeUnit)
Exports the event to XML.
void Report(ChunkedList< ProfilerEvent > Result)
Reports accumulated events to a list of events.
Contains internal states used during generation of PlantUML diagram.s
Class that keeps track of events and timing.
Class that keeps track of events and timing for one thread.
ProfilerThread CreateSubThread(string Name, ProfilerThreadType Type)
Creates a new profiler thread.
void Start()
Processing starts.
long? StoppedAt
Ticks when thread was stopped.
void NewSample(double Sample)
A new sample value has been recored
void Exception(System.Exception Exception)
Exception occurred
void Low()
Sets the (binary) state to "low".
void Stop()
Processing starts.
void ExportXml(XmlWriter Output, TimeUnit TimeUnit)
Exports events to XML.
string ToTimeStr(long Ticks, TimeUnit TimeUnit)
String representation of time, corresponding to a measured number of high-frequency clock ticks.
void Event(string Name, string Label)
Event occurred
void Interval(DateTime From, DateTime To, string Label)
Records an interval in the profiler thread.
ProfilerThreadType Type
Type of profiler thread.
void ExportPlantUmlEvents(PlantUmlStates States)
Exports events to PlantUML.
void High()
Sets the (binary) state to "high".
KeyValuePair< double, string > ToTime(long Ticks, TimeUnit TimeUnit)
Time (amount, unit), corresponding to a measured number of high-frequency clock ticks.
void Event(string Name)
Event occurred
long? StartedAt
Ticks when thread was started.
ProfilerThread(string Name, int Order, ProfilerThreadType Type, Profiler Profiler)
Class that keeps track of events and timing for one thread.
Profiler Profiler
Profiler reference.
string Key
Thread key in diagrams.
ProfilerThread Parent
Parent profiler thread, if any.
void Exception(System.Exception Exception, string Label)
Exception occurred
ProfilerThread(string Name, int Order, ProfilerThreadType Type, ProfilerThread Parent)
Class that keeps track of events and timing for one thread.
string Name
Name of thread.
void ExportPlantUmlDescription(StringBuilder Output, TimeUnit TimeUnit)
Exports events to PlantUML.
void Idle()
Thread goes idle.
void NewState(string State)
Thread changes state.
string Label
Displayable label, equal to the name by default, but can be set later during the profiling stage.
void Interval(long From, long To, string Label)
Records an interval in the profiler thread.
TimeUnit
Options for presenting time in reports.
ProfilerThreadType
Type of profiler thread.