Skip to main content

BenchmarkRunner

@webda/bench


Class: BenchmarkRunner

Defined in: packages/bench/src/runner.ts:204

Run scenarios and collect their results

Constructors​

Constructor​

new BenchmarkRunner(options): BenchmarkRunner

Defined in: packages/bench/src/runner.ts:225

Parameters​

options​

BenchmarkRunnerOptions

suite, backend, profile...

Returns​

BenchmarkRunner

Properties​

filter​

protected filter: (name) => boolean

Defined in: packages/bench/src/runner.ts:216

Scenario filter

Parameters​

name​

string

Returns​

boolean


options​

protected options: BenchmarkRunnerOptions

Defined in: packages/bench/src/runner.ts:225

suite, backend, profile...


profile​

readonly profile: BenchProfile

Defined in: packages/bench/src/runner.ts:212

Profile in use


reporters​

protected reporters: Reporter[]

Defined in: packages/bench/src/runner.ts:220

Reporters


results​

readonly results: BenchResult[] = []

Defined in: packages/bench/src/runner.ts:208

Results of the scenarios run so far

Methods​

closedLoop()​

closedLoop(scenario): Promise<BenchResult | undefined>

Defined in: packages/bench/src/runner.ts:247

Run a closed-loop scenario

Parameters​

scenario​

ClosedLoopScenario

the scenario

Returns​

Promise<BenchResult | undefined>

the result, undefined when filtered out


custom()​

custom(scenario): Promise<BenchResult | undefined>

Defined in: packages/bench/src/runner.ts:386

Run a custom scenario

Parameters​

scenario​

CustomScenario

the scenario

Returns​

Promise<BenchResult | undefined>

the result, undefined when filtered out


execute()​

protected execute(scenario, mode, measure): Promise<BenchResult | undefined>

Defined in: packages/bench/src/runner.ts:403

Run a scenario: setup, measure, verify, teardown and build its result

Parameters​

scenario​

BaseScenario

the scenario

mode​

"closed" | "open" | "custom"

how the load is generated

measure​

(latency, errors) => Promise<CustomScenarioOutcome & object>

the measurement

Returns​

Promise<BenchResult | undefined>

the result, undefined when filtered out


finish()​

finish(): Promise<BenchResult[]>

Defined in: packages/bench/src/runner.ts:503

Send the results to the reporters

Returns​

Promise<BenchResult[]>

the results


openLoop()​

openLoop(scenario): Promise<BenchResult | undefined>

Defined in: packages/bench/src/runner.ts:312

Run an open-loop scenario

Parameters​

scenario​

OpenLoopScenario

the scenario

Returns​

Promise<BenchResult | undefined>

the result, undefined when filtered out


recordError()​

protected recordError(errors, err): void

Defined in: packages/bench/src/runner.ts:491

Count an error and keep its message for the first ones

Parameters​

errors​

ErrorAccumulator

accumulator

err​

any

the error

Returns​

void


shouldRun()​

shouldRun(name): boolean

Defined in: packages/bench/src/runner.ts:237

Tell if a scenario is selected by the filter

Parameters​

name​

string

scenario name

Returns​

boolean

true when the scenario must run


workers()​

protected workers(count, offset, concurrency, maxDurationMs, op, latency, errors): Promise<number>

Defined in: packages/bench/src/runner.ts:279

Run operations with a pool of workers

Parameters​

count​

number

operations to run

offset​

number

index of the first operation

concurrency​

number

number of workers

maxDurationMs​

number

stop starting operations after this duration

op​

(index, worker) => Promise<void>

the operation

latency​

LatencyRecorder | undefined

recorder, undefined to discard the latencies

errors​

ErrorAccumulator

error accumulator

Returns​

Promise<number>

the number of operations run