Class Tracer
- Namespace
- Support
- Assembly
- Support.dll
Provides a simple way to trace the execution of algorithms.
public static class Tracer
- Inheritance
-
Tracer
- Inherited Members
Examples
Here is how to the tracer in a recursive implementation of the Fibonacci algorithm:
It looks like the sample you are looking for does not exist.
Remarks
To use this class, you must define the WITH_INSTRUMENTATION conditional compilation symbol. You need to call Init() at the beginning of your program. Then, you can use the Trace(string) methods to trace execution of algorithms.
Properties
TraceList
public static IEnumerable<TraceElement> TraceList { get; }
Property Value
WriteToConsole
Gets or sets a value indicating whether the trace events should be written to the console.
public static bool WriteToConsole { get; set; }
Property Value
- See Also
Methods
DecLevel()
Decreases the indentation level for tracing. Should be paired with a corresponding call to IncLevel().
[Conditional("WITH_INSTRUMENTATION")]
public static void DecLevel()
IncLevel()
Increases the indentation level for tracing. Should be paired with a corresponding call to DecLevel().
[Conditional("WITH_INSTRUMENTATION")]
public static void IncLevel()
Init()
Initializes the tracing process. Should be called at the beginning of the program.
[Conditional("WITH_INSTRUMENTATION")]
public static void Init()
Trace(string)
Records a trace event with a specific name.
[Conditional("WITH_INSTRUMENTATION")]
public static void Trace(string name)
Parameters
name
stringThe name of the trace event.
TraceIteration<TIndex>(string, TIndex)
Records a trace event for an iteration with a specific name, capturing the index of the current iteration.
[Conditional("WITH_INSTRUMENTATION")]
public static void TraceIteration<TIndex>(string name, TIndex index)
Parameters
name
stringThe name of the trace event.
index
TIndexThe index of the current iteration.
Type Parameters
TIndex
The type of the index used in the iteration.
TraceIteration<TIndex>(TIndex)
Records a trace event for an iteration, capturing the index of the current iteration.
[Conditional("WITH_INSTRUMENTATION")]
public static void TraceIteration<TIndex>(TIndex index)
Parameters
index
TIndexThe index of the current iteration.
Type Parameters
TIndex
The type of the index used in the iteration.
TraceIteration<TIndex, T>(TIndex, T)
Records a trace event for an iteration, capturing both the index and the value of the current iteration.
[Conditional("WITH_INSTRUMENTATION")]
public static void TraceIteration<TIndex, T>(TIndex index, T value)
Parameters
index
TIndexThe index of the current iteration.
value
TThe value of the current iteration.
Type Parameters
TIndex
The type of the index used in the iteration.
T
The type of the value in the current iteration.
Trace<T>(string, T)
Records a trace event with a specific name and an associated value.
[Conditional("WITH_INSTRUMENTATION")]
public static void Trace<T>(string name, T value)
Parameters
name
stringThe name of the trace event.
value
TThe value associated with the trace event.
Type Parameters
T
The type of the value associated with the trace event.
Events
EventTraced
An event that is raised when a trace event is recorded.
public static event Action<TraceElement> EventTraced