Bee.TinyProfiler2
Methods shared by both and
Profile a section tracked by an IDisposable object
TraceEvent duration is calculated the first time Dispose is called.
Label of what is being profiled. If omitted, this is the name of the calling function.
A dictionary of metadata associated with the event.
An IDisposable object tracking the profiled section.
Profiles the submitted Action
Label of what is being profiled.
Code to be profiled.
A dictionary of metadata associated with the event.
Profiles the submitted Func
Label of what is being profiled.
Code to be profiled.
A dictionary of metadata associated with the event.
Profiles the submitted Action
Code to be profiled.
A dictionary of metadata associated with the event.
Default initialized to calling member name
Profiles the submitted Func
Code to be profiled.
A dictionary of metadata associated with the event.
Default initialized to calling member name
A profiler capable of emitting a chrome trace report
Global profiler instance
Resets the global instance
Absolute time of profiler instantiation
Can be used to align event timestamps from other systems to this profiler instance.
Time that has passed since profiler instantiation
Get or implicitly create a track for the current thread
A track need at least one event to be visible in the chrome trace report
Default options for writing a chrome trace report
Create a new profiler instance
Setup a new track
A track for the most common use case represents a thread.
But a user can also explicitly setup a track to hold submitted events and sections.
Name of the track
An instance assigned to the created track
Write a chrome trace events to stream
If the extension of the file passed is '.traceevents' this method will invoke WriteChromeTraceEvents(), otherwise it will call WriteChromeTrace()
See .
output file
chrome trace serialization options
Write a chrome trace report data to file
output file
chrome trace serialization options
Write a chrome trace events to stream
This is a list of trace events that can later be concatenated with reports from other processes or sessions.
See .
output file
chrome trace serialization options
Write a chrome trace report data to stream
output stream
chrome trace serialization options
Write a chrome trace events to stream
This is a list of trace events that can later be concatenated with reports from other processes or sessions.
See .
output stream
chrome trace serialization options
A track in the chrome trace report is the same as "lane" or "thread"
A track is either an explicitly created track or implicitly created
for the current thread .
Note that when creating events manually using an external clock source. Make sure timestamp is relative to .
One way to do that is to use .
Track Id
Explicitly created tracks use upper 32 bits to generate unique ids while thread tracks use the lower 32 bits
to store
Name of the track
Thread tracks copy at the time of track creation
Time that has elapsed since the profiler was instantiated
Time of profiler instantiation
Create track from thread
Create track from name
Create and register a trace event with the profiler
Duration can be set after the fact.
Start time of the event. This should be relative instantiation time of the profiler. In most cases ElapsedTimeSinceInstantiation.
Label of what is being profiled. If omitted, this is the name of the calling function.
A dictionary of metadata associated with the event.
A trace event initialized according to parameters
Create and register a trace event with the profiler
Timestamp of the event will be set to current time at event creation.
Duration can be set after the fact.
Label of what is being profiled. If omitted, this is the name of the calling function.
A dictionary of metadata associated with the event.
A trace event initialized according to parameters
Create and register a trace event with the profiler
Duration can be set after the fact.
Start time of the event.
Label of what is being profiled. If omitted, this is the name of the calling function.
A dictionary of metadata associated with the event.
A trace event initialized according to parameters
Sets duration of the TraceEvent to ElapsedTimeSinceInstantiation - TraceEvent.Timestamp
The event to receive duration
The event
Sets duration of the TraceEvent
The event to receive duration
Duration of the event
The event
TraceEvent
Chrome trace serialization options
If an event has a duration less than this it will be excluded from the report
1 microsecond is default
Id of the process
Defaults to current process id.
Process name as seen in the chrome trace UI
Defaults to entry assembly name.
Process sort index
This index decide how different processes are sorted in the chrome trace report.
Lower indices, including negative ones are sorted topmost.
Additional trace event files
Any additional trace event files that should be merged with the current report.
You need to pass a delegate returning the file instead of the file itself, as this allows you to start writing out the profile data,
before all ExternalTraceFiles are ready. Only when the writing process is actually ready to start processing ExternalTraceFiles it will
call your delegate, and at that time you need to ensure that the path your delegate returns exists.
A dictionary of metadata about the machine that will be emitted in the header
IDisposable struct that records duration on
Record duration
TraceEvents data
We keep structs in a separate array from managed references to create less GC pressure.
We also keep a separate a regular list for Metadata as we assume that usage of metadata is rare and by using a
regular list we can create our own sparse array.
ChromeTrace is responsible for json serialization of TraceEvent data
The implementation is highly specific to the profiler implementation and should not be seen in any way as a
general purpose utility.
BucketArray is optimized for quick lookup and insert
BucketArray will only lock the first time an entry is inserted into a bucket. Bucket sizes grow exponentially.
For an initial bucket size of 1024 that means there are at most 21 buckets for a 32 bit integer range.
Note! get by index isn't protected, which means it's undefined behavior to access an item not previously written.
It may throw a NullReferenceException or return default(T) depending on the situation.