PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.Benchmark Class Reference

Provides a static Time method which times running the provided action the specified number of times. More...

Static Public Member Functions

static void PrintTime (string label, Action toRun, int iterations)
 Times the provided action, run the provided number of iterations, and then prints out the run time to stdout.
 
static async Task PrintTimeAsync (string label, Func< Task > toRun, int iterations)
 Times the provided action, run the provided number of iterations, and then prints out the run time to stdout.
 
static TimeSpan Time (Action action)
 Time a single iteration of the provided action.
 
static TimeSpan Time (Action action, int iterations)
 Time an action, run the specified number of times, and return the total time taken.
 
static async Task< TimeSpan > TimeAsync (Func< Task > action)
 Time a single iteration of the provided async action.
 
static async Task< TimeSpan > TimeAsync (Func< Task > action, int iterations)
 Time an async action, run the specified number of times, and return the total time taken.
 

Detailed Description

Provides a static Time method which times running the provided action the specified number of times.

Member Function Documentation

◆ PrintTime()

static void PeanutButter.Utils.Benchmark.PrintTime ( string  label,
Action  toRun,
int  iterations 
)
static

Times the provided action, run the provided number of iterations, and then prints out the run time to stdout.

Parameters
label
toRun
iterations

◆ PrintTimeAsync()

static async Task PeanutButter.Utils.Benchmark.PrintTimeAsync ( string  label,
Func< Task >  toRun,
int  iterations 
)
static

Times the provided action, run the provided number of iterations, and then prints out the run time to stdout.

Parameters
label
toRun
iterations

◆ Time() [1/2]

static TimeSpan PeanutButter.Utils.Benchmark.Time ( Action  action)
static

Time a single iteration of the provided action.

Parameters
action
Returns

◆ Time() [2/2]

static TimeSpan PeanutButter.Utils.Benchmark.Time ( Action  action,
int  iterations 
)
static

Time an action, run the specified number of times, and return the total time taken.

Parameters
action
iterations
Returns

◆ TimeAsync() [1/2]

static async Task< TimeSpan > PeanutButter.Utils.Benchmark.TimeAsync ( Func< Task >  action)
static

Time a single iteration of the provided async action.

Parameters
action
Returns

◆ TimeAsync() [2/2]

static async Task< TimeSpan > PeanutButter.Utils.Benchmark.TimeAsync ( Func< Task >  action,
int  iterations 
)
static

Time an async action, run the specified number of times, and return the total time taken.

Parameters
action
iterations
Returns

The documentation for this class was generated from the following file: