Skip to content

Commit 4a46a20

Browse files
committed
Profiling: clean up.
1 parent 21dbeef commit 4a46a20

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Linq;
3+
4+
namespace PostSharp.Samples.Profiling
5+
{
6+
internal struct ExcludedTimeData
7+
{
8+
public long CpuTime;
9+
public long ThreadTime;
10+
11+
public ExcludedTimeData(long cpuTime, long threadTime)
12+
{
13+
this.CpuTime = cpuTime;
14+
this.ThreadTime = threadTime;
15+
}
16+
}
17+
}

Framework/PostSharp.Samples.Profiling/MethodCallData.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace PostSharp.Samples.Profiling
55
{
66
public struct MethodCallData
77
{
8-
98
internal MetricData MetricData;
109

1110
private long _kernelTimestamp;
@@ -23,7 +22,7 @@ internal void Start(MetricMetadata metadata)
2322
this.Resume();
2423
}
2524

26-
public bool IsNull => this._asyncTimestamp == 0;
25+
internal bool IsNull => this._asyncTimestamp == 0;
2726

2827
internal MetricMetadata Metadata { get; private set; }
2928

Framework/PostSharp.Samples.Profiling/MetricData.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@
66

77
namespace PostSharp.Samples.Profiling
88
{
9-
internal struct ExcludedTimeData
10-
{
11-
public long CpuTime;
12-
public long ThreadTime;
13-
14-
public ExcludedTimeData(long cpuTime, long threadTime)
15-
{
16-
this.CpuTime = cpuTime;
17-
this.ThreadTime = threadTime;
18-
}
19-
}
20-
219
internal struct MetricData
2210
{
2311
public long CpuTime;

Framework/PostSharp.Samples.Profiling/ProfiledMethod.cs renamed to Framework/PostSharp.Samples.Profiling/MetricMetadata.cs

File renamed without changes.

Framework/PostSharp.Samples.Profiling/Program.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@ internal class Program
1414
static volatile bool cancel;
1515
private static void Main(string[] args)
1616
{
17-
TelemetryConfiguration telemetryConfiguration = new TelemetryConfiguration("4fe9fc01-23cc-40ee-94e1-6dc532d861b9");
17+
// TODO: Add your own instrumentation key.
18+
const string instrumentationKey = "4fe9fc01-23cc-40ee-94e1-6dc532d861b9";
19+
20+
TelemetryConfiguration telemetryConfiguration = new TelemetryConfiguration(instrumentationKey);
1821
TelemetryClient telemetryClient = new TelemetryClient(telemetryConfiguration);
1922
if ( ! telemetryClient.IsEnabled() )
2023
{
2124
Console.Write("TelemetryClient is not enabled.");
2225
return;
2326
}
24-
ProfilingServices.Initialize(telemetryClient, TimeSpan.FromSeconds(10));
27+
TimeSpan period = TimeSpan.FromSeconds(10);
28+
ProfilingServices.Initialize(telemetryClient, );
29+
30+
Console.WriteLine($"Sampling every {period.TotalSeconds} seconds. Press Ctrl-C to stop, then wait a few seconds for completion.");
2531

2632
Console.CancelKeyPress += OnCancel;
2733

@@ -44,7 +50,7 @@ private static void Main(string[] args)
4450

4551
private static void OnCancel(object sender, ConsoleCancelEventArgs e)
4652
{
47-
Console.WriteLine("Cancelling.");
53+
Console.WriteLine("Cancelling. Please wait until completion, otherwise the Application Insights buffer won't be flushed.");
4854
cancel = true;
4955
e.Cancel = true;
5056
}

0 commit comments

Comments
 (0)