-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathInstrumentation.cs
More file actions
38 lines (34 loc) · 1.11 KB
/
Instrumentation.cs
File metadata and controls
38 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Diagnostics;
namespace InkkSlinger.Tests;
public static class Instrumentation
{
/// <summary>
/// Writes a line to the test output that can be captured by InstrumentationCapture
/// and also appears in the test console output.
/// </summary>
[DebuggerStepThrough]
public static void Trace(string message)
{
var line = $"[INSTRUMENT] {message}";
System.Diagnostics.Trace.WriteLine(line);
Console.Out.WriteLine(line);
}
/// <summary>
/// Writes a timing entry in the standard format parsed by InstrumentationCapture.TryParseTiming.
/// Example: "MyMethod took 1234us"
/// </summary>
[DebuggerStepThrough]
public static void TraceTiming(string method, long microseconds)
{
Trace($"{method} took {microseconds}us");
}
/// <summary>
/// Writes a counter entry in the standard format parsed by InstrumentationCapture.TryParseCounter.
/// Example: "MyMethod #42"
/// </summary>
[DebuggerStepThrough]
public static void TraceCounter(string method, int count)
{
Trace($"{method} #{count}");
}
}