Measure the elapsed time sections and provide better log text. More...
Public Member Functions | |
TimeRecorder (string name=null, bool start=true) | |
Create a new recorder and optional to start immediately. More... | |
override string | ToString () |
Return the current state, including all recorded sections. More... | |
void | Start () |
Start or resume measuring. More... | |
void | Stop (string section=null, bool log=false) |
Stop measuring, optional to record if the section name set. More... | |
void | Record (string section="") |
Record the current elapsed time, optional to append the section name to the default index. More... | |
void | Reset () |
Stop and reset all records. More... | |
Static Public Member Functions | |
static TimeRecorder | Run (Action< int > action, string name=null, int count=10000, bool log=true) |
Run the action in the specified count of the times, then stop and log the elapsed time. More... | |
Public Attributes | |
readonly string | name |
The name. More... | |
bool | running => _watch.IsRunning |
Determine if the timer is currently running. More... | |
long | elapsed => _watch.ElapsedMilliseconds |
Get the total elapsed time in milliseconds. More... | |
Measure the elapsed time sections and provide better log text.
TimeRecorder | ( | string | name = null , |
bool | start = true |
||
) |
Create a new recorder and optional to start immediately.
name | Name. |
start | Start. |
|
static |
Run the action in the specified count of the times, then stop and log the elapsed time.
action | The action, the parameter is the current count started from 0. |
name | The name. |
count | The count. |
log | If to log when done. |
override string ToString | ( | ) |
Return the current state, including all recorded sections.
Include this's name
, running
state, and the current elapsed
time at the first row. Then each row of section, i.e., recording time, duration, and the name at the end for better format.
string
represents this.void Start | ( | ) |
Start or resume measuring.
void Stop | ( | string | section = null , |
bool | log = false |
||
) |
Stop measuring, optional to record if the section
name set.
section | Section name. |
log | If to log when done. |
void Record | ( | string | section = "" | ) |
Record the current elapsed time, optional to append the section
name to the default index.
section | Section name. |
void Reset | ( | ) |
Stop and reset all records.
readonly string name |
The name.
bool running => _watch.IsRunning |
Determine if the timer is currently running.
long elapsed => _watch.ElapsedMilliseconds |
Get the total elapsed time in milliseconds.