Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 2d8a431

Browse files
Add source code annotations (#5)
* docs: add annotations to count data cooker * docs: add annotations to telemetry data cooker * docs: add annotations to timeline data cooker * docs: add annotations to events * docs: add annotations to tables * docs: add source parser and processing source annotations
1 parent b71b7b6 commit 2d8a431

13 files changed

+957
-267
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ msbuild.wrn
3737
.vs/
3838
TestResult.xml
3939

40+
# Documentation
41+
docs

WPAPlugin/Constants/WperfPluginConstants.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,63 @@ namespace WPAPlugin.Constants
3535
public static class WperfPluginConstants
3636
{
3737
// Event Identifiers used by Data cookers
38+
39+
/// <summary>
40+
/// Constant added to counting events parsed from a single count .json input file.
41+
/// </summary>
3842
public const string PerformanceCounterEventKey = "PerformanceCounterEvent";
43+
44+
/// <summary>
45+
/// WperfPluginConstants.PerformanceCounterTimelineEventKey: constant added to counting events parsed from a timeline count .json input file.
46+
/// </summary>
3947
public const string PerformanceCounterTimelineEventKey = "PerformanceCounterTimelineEvent";
48+
49+
/// <summary>
50+
/// Constant added to telemetry events parsed from a timeline .json input file.
51+
/// </summary>
4052
public const string TelemetryEventKey = "TelemetryEvent";
4153

4254
// Parser ID (There should be no reason to have multiple parsers as of now)
55+
56+
/// <summary>
57+
/// Constant string identifier of WperfSourceParser
58+
/// </summary>
4359
public const string ParserId = "WperfSourceParser";
4460

4561
// Cooker IDs
62+
63+
/// <summary>
64+
/// Constant string identifier of WperfTimelineDataCooker
65+
/// </summary>
4666
public const string TimelineCookerId = "WperfDataCooker";
67+
68+
/// <summary>
69+
/// Constant string identifier of WperfCountDataCooker
70+
/// </summary>
4771
public const string CountCookerId = "WperfCountDataCooker";
72+
73+
/// <summary>
74+
/// Constant string identifier of WperfTelemetryDataCooker
75+
/// </summary>
4876
public const string TelemetryCookerId = "WperfTelemetryCooker";
4977

50-
public static readonly string[] WperfPresetMetrics = { "MPKI", "per TLB access", "per branch", "per cache access", "per cycle", "percent of cycles", "percent of operations", "percent of slots" };
78+
public static readonly string[] WperfPresetMetrics =
79+
{
80+
"MPKI",
81+
"per TLB access",
82+
"per branch",
83+
"per cache access",
84+
"per cycle",
85+
"percent of cycles",
86+
"percent of operations",
87+
"percent of slots"
88+
};
5189

5290
// Cooker Paths
91+
/// <summary>
92+
/// In order for the events processd by the DataCooker to be consumed by the tables, each DataCooker requires declaring a path that maps itself with the appropriate DataSource.
93+
/// </summary>
94+
5395
public static readonly DataCookerPath CookerPath = DataCookerPath.ForSource(
5496
ParserId,
5597
TimelineCookerId

WPAPlugin/DataCookers/WperfCountDataCooker.cs

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,35 @@
2828
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31+
using System.Collections.Generic;
32+
using System.Collections.ObjectModel;
33+
using System.Threading;
3134
using Microsoft.Performance.SDK;
3235
using Microsoft.Performance.SDK.Extensibility;
3336
using Microsoft.Performance.SDK.Extensibility.DataCooking;
3437
using Microsoft.Performance.SDK.Extensibility.DataCooking.SourceDataCooking;
35-
using System.Collections.Generic;
36-
using System.Collections.ObjectModel;
37-
using System.Threading;
3838
using WPAPlugin.Constants;
3939
using WPAPlugin.Events;
4040

4141
namespace WPAPlugin.DataCookers
4242
{
43+
/// <summary>
44+
/// WperfCountDataCooker is a SourceDataCooker that passes the counting WperfEvents as is.
45+
/// </summary>
4346
public class WperfCountDataCooker : SourceDataCooker<WperfEvent, WperfSourceParser, string>
4447
{
4548
private readonly List<WperfEvent> wperfEvents;
4649

50+
/// <summary>
51+
/// Data processed by the DataCooker needs to be stored in a field annotated with DataOutput
52+
/// </summary>
53+
/// <example>
54+
/// <code>
55+
/// private readonly List<WperfEvent> wperfEvents;
56+
/// [DataOutput]
57+
/// public IReadOnlyList<WperfEvent> WperfEvents { get; }
58+
/// </code>
59+
/// </example>
4760
[DataOutput]
4861
public IReadOnlyList<WperfEvent> WperfEvents { get; }
4962

@@ -56,6 +69,21 @@ public WperfCountDataCooker()
5669

5770
public override string Description => "Passes on the counting data as is";
5871

72+
/// <summary>
73+
/// WperfCountDataCooker filters the counting events from all the processed WperfEvents by the WperfSourceParser through the DataKeys field.
74+
/// </summary>
75+
/// <example>
76+
/// <code>
77+
/// public override ReadOnlyHashSet<string> DataKeys =>
78+
/// new ReadOnlyHashSet<string>(
79+
/// new HashSet<string>
80+
/// {
81+
/// WperfPluginConstants.PerformanceCounterEventKey,
82+
/// WperfPluginConstants.PerformanceCounterTimelineEventKey
83+
/// }
84+
/// );
85+
/// </code>
86+
/// </example>
5987
public override ReadOnlyHashSet<string> DataKeys =>
6088
new ReadOnlyHashSet<string>(
6189
new HashSet<string>
@@ -65,6 +93,24 @@ public WperfCountDataCooker()
6593
}
6694
);
6795

96+
/// <summary>
97+
/// Data processing happens at the CookDataElement level that takes the data marked as ready to be processed from the SourceParser, as well as the WperfSourceParser instance to extract context if needed.
98+
/// </summary>
99+
/// <example>
100+
/// <code>
101+
/// public override DataProcessingResult CookDataElement(
102+
/// WperfEvent data,
103+
/// WperfSourceParser context,
104+
/// CancellationToken cancellationToken
105+
///)
106+
///{
107+
/// ... // process data and add to the field annotated with [DataOutput]
108+
/// wperfEvents.Add(cookedData);
109+
///
110+
/// return DataProcessingResult.Processed;
111+
///}
112+
/// </code>
113+
/// </example>
68114
public override DataProcessingResult CookDataElement(
69115
WperfEvent data,
70116
WperfSourceParser context,

WPAPlugin/DataCookers/WperfTelemetryDataCooker.cs

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,35 @@
2828
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31+
using System.Collections.Generic;
32+
using System.Collections.ObjectModel;
33+
using System.Threading;
3134
using Microsoft.Performance.SDK;
3235
using Microsoft.Performance.SDK.Extensibility;
3336
using Microsoft.Performance.SDK.Extensibility.DataCooking;
3437
using Microsoft.Performance.SDK.Extensibility.DataCooking.SourceDataCooking;
35-
using System.Collections.Generic;
36-
using System.Collections.ObjectModel;
37-
using System.Threading;
3838
using WPAPlugin.Constants;
3939
using WPAPlugin.Events;
4040

4141
namespace WPAPlugin.DataCookers
4242
{
43-
public class WperfTelemetryDataCooker
44-
: SourceDataCooker<WperfEvent, WperfSourceParser, string>
43+
/// <summary>
44+
/// WperfTelemetryDataCooker is a SourceDataCooker that adds the relative start and end time to the counting WperfEvents.
45+
/// </summary>
46+
public class WperfTelemetryDataCooker : SourceDataCooker<WperfEvent, WperfSourceParser, string>
4547
{
4648
private readonly List<WperfEventWithRelativeTimestamp> wperfEventWithRelativeTimestamps;
4749

50+
/// <summary>
51+
/// Data processed by the DataCooker needs to be stored in a field annotated with DataOutput
52+
/// </summary>
53+
/// <example>
54+
/// <code>
55+
/// private readonly List<WperfEventWithRelativeTimestamp> wperfEventWithRelativeTimestamps;
56+
/// [DataOutput]
57+
/// public IReadOnlyList<WperfEventWithRelativeTimestamp> WperfEventWithRelativeTimestamps { get; }
58+
/// </code>
59+
/// </example>
4860
[DataOutput]
4961
public IReadOnlyList<WperfEventWithRelativeTimestamp> WperfEventWithRelativeTimestamps { get; }
5062

@@ -60,11 +72,40 @@ public WperfTelemetryDataCooker()
6072

6173
public override string Description => "Adds relative timestamps to telemetry events";
6274

75+
/// <summary>
76+
/// WperfTimelineDataCooker filters the telemetry events from all the processed WperfEvents by the WperfSourceParser through the DataKeys field.
77+
/// </summary>
78+
/// <example>
79+
/// <code>
80+
/// public override ReadOnlyHashSet<string> DataKeys =>
81+
/// new ReadOnlyHashSet<string>(
82+
/// new HashSet<string> { WperfPluginConstants.TelemetryEventKey }
83+
/// );
84+
/// </code>
85+
/// </example>
6386
public override ReadOnlyHashSet<string> DataKeys =>
6487
new ReadOnlyHashSet<string>(
6588
new HashSet<string> { WperfPluginConstants.TelemetryEventKey }
6689
);
6790

91+
/// <summary>
92+
/// Data processing happens at the CookDataElement level that takes the data marked as ready to be processed from the SourceParser, as well as the WperfSourceParser instance to extract context if needed.
93+
/// </summary>
94+
/// <example>
95+
/// <code>
96+
/// public override DataProcessingResult CookDataElement(
97+
/// WperfEvent data,
98+
/// WperfSourceParser context,
99+
/// CancellationToken cancellationToken
100+
/// )
101+
/// {
102+
/// ... // process data and add to the field annotated with [DataOutput]
103+
/// wperfEventWithRelativeTimestamps.Add(cookedEvent);
104+
///
105+
/// return DataProcessingResult.Processed;
106+
/// }
107+
/// </code>
108+
/// </example>
68109
public override DataProcessingResult CookDataElement(
69110
WperfEvent data,
70111
WperfSourceParser context,

WPAPlugin/DataCookers/WperfTimelineDataCooker.cs

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,36 @@
2828
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31+
using System.Collections.Generic;
32+
using System.Collections.ObjectModel;
33+
using System.Threading;
3134
using Microsoft.Performance.SDK;
3235
using Microsoft.Performance.SDK.Extensibility;
3336
using Microsoft.Performance.SDK.Extensibility.DataCooking;
3437
using Microsoft.Performance.SDK.Extensibility.DataCooking.SourceDataCooking;
35-
using System.Collections.Generic;
36-
using System.Collections.ObjectModel;
37-
using System.Threading;
3838
using WPAPlugin.Constants;
3939
using WPAPlugin.Events;
4040

4141
namespace WPAPlugin.DataCookers
4242
{
43-
public class WperfTimelineDataCooker
44-
: SourceDataCooker<WperfEvent, WperfSourceParser, string>
43+
/// <summary>
44+
/// WperfCountDataCooker is a SourceDataCooker that adds the relative start and end time to the counting WperfEvents.
45+
/// </summary>
46+
public class WperfTimelineDataCooker : SourceDataCooker<WperfEvent, WperfSourceParser, string>
4547
{
4648
private readonly List<WperfEventWithRelativeTimestamp> wperfEventWithRelativeTimestamps;
4749

50+
/// <summary>
51+
/// Data processed by the DataCooker needs to be stored in a field annotated with DataOutput
52+
/// </summary>
53+
/// <example>
54+
/// <code>
55+
/// private readonly List<WperfEventWithRelativeTimestamp> wperfEventWithRelativeTimestamps;
56+
///
57+
/// [DataOutput]
58+
/// public IReadOnlyList<WperfEventWithRelativeTimestamp> WperfEventWithRelativeTimestamps { get; }
59+
/// </code>
60+
/// </example>
4861
[DataOutput]
4962
public IReadOnlyList<WperfEventWithRelativeTimestamp> WperfEventWithRelativeTimestamps { get; }
5063

@@ -60,11 +73,43 @@ public WperfTimelineDataCooker()
6073

6174
public override string Description => "Adds relative timestamps to counting events";
6275

76+
/// <summary>
77+
/// WperfTimelineDataCooker filters the counting events from all the processed WperfEvents by the WperfSourceParser through the DataKeys field.
78+
/// </summary>
79+
/// <example>
80+
/// <code>
81+
/// public override ReadOnlyHashSet<string> DataKeys =>
82+
/// new ReadOnlyHashSet<string>(
83+
/// new HashSet<string>
84+
/// {
85+
/// WperfPluginConstants.PerformanceCounterTimelineEventKey
86+
/// }
87+
/// );
88+
/// </code>
89+
/// </example>
6390
public override ReadOnlyHashSet<string> DataKeys =>
6491
new ReadOnlyHashSet<string>(
6592
new HashSet<string> { WperfPluginConstants.PerformanceCounterTimelineEventKey }
6693
);
6794

95+
/// <summary>
96+
/// Data processing happens at the CookDataElement level that takes the data marked as ready to be processed from the SourceParser, as well as the WperfSourceParser instance to extract context if needed.
97+
/// </summary>
98+
/// <example>
99+
/// <code>
100+
/// public override DataProcessingResult CookDataElement(
101+
/// WperfEvent data,
102+
/// WperfSourceParser context,
103+
/// CancellationToken cancellationToken
104+
/// )
105+
/// {
106+
/// ... // process data and add to the field annotated with [DataOutput]
107+
/// wperfEventWithRelativeTimestamps.Add(cookedEvent);
108+
///
109+
/// return DataProcessingResult.Processed;
110+
/// }
111+
/// </code>
112+
/// </example>
68113
public override DataProcessingResult CookDataElement(
69114
WperfEvent data,
70115
WperfSourceParser context,

WPAPlugin/Events/WperfEvent.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,68 @@
3232

3333
namespace WPAPlugin.Events
3434
{
35+
/// <summary>
36+
/// WperfEvent is a class that stores WindowsPerf events.
37+
/// In order to keep the plugin structure straight forward and not resorting to multiple
38+
/// SourceParsers, counting events and timeline events are stored in WperfEvent instances
39+
/// by sharing their common properties and ignoring unrelated fields.
40+
/// </summary>
3541
public class WperfEvent : IKeyedDataType<string>
3642
{
3743
// Common fields
44+
45+
/// <summary>
46+
/// int representing the core number of said event.
47+
/// </summary>
3848
public int CoreNumber { get; set; }
49+
50+
/// <summary>
51+
/// double represeting the value of the count/telemetry.
52+
/// </summary>
3953
public double Value { get; set; }
54+
55+
/// <summary>
56+
/// string representing name of the event/metric.
57+
/// </summary>
4058
public string Name { get; set; }
59+
60+
/// <summary>
61+
/// double representing the start time of the event.
62+
/// </summary>
4163
public double StartTime { get; set; }
64+
65+
/// <summary>
66+
/// double representing the end time of the event.
67+
/// </summary>
4268
public double EndTime { get; set; }
69+
70+
/// <summary>
71+
/// string used in filtering the events by the DataCookers.
72+
/// </summary>
4373
public string Key { get; set; }
4474

4575
// Counting fields
76+
/// <summary>
77+
/// string representing the counting event index.
78+
/// </summary>
4679
public string Index { get; set; }
80+
81+
/// <summary>
82+
/// string representing the counting event note.
83+
/// </summary>
4784
public string Note { get; set; }
4885

4986
// Telemetry Fields
87+
88+
/// <summary>
89+
/// string representing the metric unit.
90+
/// </summary>
5091
public string Unit { get; set; }
51-
public string ProductName { get; set; }
5292

93+
/// <summary>
94+
/// string representing the metric product name.
95+
/// </summary>
96+
public string ProductName { get; set; }
5397

5498
public WperfEvent() { }
5599

0 commit comments

Comments
 (0)