Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ProfilerEvent.cs
1using System.Text;
2using System.Xml;
4
6{
10 public abstract class ProfilerEvent
11 {
12 private readonly long ticks;
13 private readonly ProfilerThread thread;
14
21 {
22 this.ticks = Ticks;
23 this.thread = Thread;
24 }
25
29 public long Ticks => this.ticks;
30
34 public ProfilerThread Thread => this.thread;
35
39 public abstract string EventType
40 {
41 get;
42 }
43
50 public virtual void ExportXml(XmlWriter Output, ProfilerEvent Previous, TimeUnit TimeUnit)
51 {
52 Output.WriteStartElement(this.EventType);
53 this.ExportXmlAttributes(Output, Previous, TimeUnit);
54 Output.WriteEndElement();
55 }
56
63 public virtual void ExportXmlAttributes(XmlWriter Output, ProfilerEvent Previous, TimeUnit TimeUnit)
64 {
65 Output.WriteAttributeString("ticks", this.ticks.ToString());
66 Output.WriteAttributeString("time", this.thread.ToTimeStr(this.ticks, TimeUnit));
67
68 if (!(Previous is null))
69 {
70 Output.WriteAttributeString("elapsedTicks", (this.ticks - Previous.ticks).ToString());
71 Output.WriteAttributeString("elapsedTime", this.thread.ToTimeStr(this.ticks - Previous.ticks, TimeUnit));
72 }
73 }
74
79 public virtual void ExportPlantUml(PlantUmlStates States)
80 {
81 StringBuilder Output = States.GetBuilder(this.ticks);
82 Output.Append(this.thread.Key);
83 Output.Append(" is ");
84
85 string s = this.PlantUmlState;
86
87 if (s.StartsWith("{") && s.EndsWith("}"))
88 Output.AppendLine(s);
89 else
90 {
91 Output.Append("\"");
92 Output.Append(s.Replace("\"", "'"));
93 Output.AppendLine("\"");
94 }
95 }
96
100 public abstract string PlantUmlState
101 {
102 get;
103 }
104
108 public virtual void ExportPlantUmlPreparation()
109 {
110 // Do nothing by defualt.
111 }
112
117 public virtual void Accumulate(Accumulator Accumulator)
118 {
119 Accumulator.AddAsIs(this);
120 }
121 }
122}
Abstract base class for profiler events.
ProfilerEvent(long Ticks, ProfilerThread Thread)
Abstract base class for profiler events.
virtual void Accumulate(Accumulator Accumulator)
Accumulates the event.
virtual void ExportPlantUml(PlantUmlStates States)
Exports events to PlantUML.
abstract string EventType
Type of event.
virtual void ExportXmlAttributes(XmlWriter Output, ProfilerEvent Previous, TimeUnit TimeUnit)
Exports event attributes to XML.
abstract string PlantUmlState
PlantUML state representing event.
virtual void ExportXml(XmlWriter Output, ProfilerEvent Previous, TimeUnit TimeUnit)
Exports the event to XML.
ProfilerThread Thread
Profiler thread generating the event.
virtual void ExportPlantUmlPreparation()
Prepares the event for export to PlantUML
void AddAsIs(ProfilerEvent Event)
Adds an event, as-is.
Definition: Accumulator.cs:33
Contains internal states used during generation of PlantUML diagram.s
StringBuilder GetBuilder(long Ticks)
Gets the PlantUML output StringBuilder associated with a time-point.
Class that keeps track of events and timing for one thread.
TimeUnit
Options for presenting time in reports.
Definition: Profiler.cs:16