Extends: EventEmitter
Arguments:
- options -
object
- optional - Default:{}
- warmup -
boolean
- optional - Default:true
- samples -
number
- optional - Default:10
- meta -
Meta
- optional - Default:{}
- warmup -
Context
A property that will be passed as the first argument to each lifecyle method and run script.
Meta
A property that represents general information about the benchmark instance. The title is defaulted to process.argv[1]
(generally the path of the benchmark script).
Map<string, Array<PerformanceEntry>>
This property is updated after the benchmark suite executes.
number
The number of samples the benchmark suite will run. This property can be modified at any point prior to calling benchmark.start()
.
boolean
When set to true
, the warmup step will run. This property can be modified at any point prior to calling benchmark.start()
.
Arguments:
- func -
FunctionWithContext<Context>
- required
Lifecycle method for adding a function that executes after all other scripts are executed.
Arguments:
- func -
FunctionWithContext<Context>
- required
Lifecycle method for adding a function that executes after each run script is executed.
Arguments:
- func -
FunctionWithContext<Context>
- required
Lifecycle method for adding a function that executes before all scripts are executed.
Arguments:
- func -
FunctionWithContext<Context>
- required
Lifecycle method for adding a function that executes before each run script is executed.
Arguments:
- id -
string
- required - file -
string
- required
Add a run to the benchmark instance. The id
must be unique and file
must be the absolute path to the script.
Returns: Promise<void>
Executes the benchmark suite. Resolves once it completes execution. Does not rethrow errors thrown during execution. Errors are emitted through the error
event.
Emitted at the beginning of the microtask queued during the constructor. It will not be emitted if no runs have been added.
Emitted at the end of the microtask after all runs have been executed.
Emitted whenever an error is thrown. Will return the thrown error.
const [error] = await once(benchmark, "error");
(context: Context, ...extraArgs: unknown[]) => void | Promise<void>
- title -
string
- optional - description -
string
- optional
Execute tests using pnpm test