Skip to main content
Version: 9.0.0

Benchmark

benchmark

Method allowing to measure some metrics and to compare them.

ParameterTypeDescription
{ name, functions, options }{name: string; functions: {name: string;fn: () => Promise<void>;}[];options?: BenchmarkOptions;}Name of the benchmark action.

BenchmarkOptions

ParameterTypeDescription
reporters{ json?: {file: string;};csv?: {file: string;};html?: {file: string;};htmlTable?: {file: string;};}Different types of reports available.

Usage Example

        const benchmarkResult = await I.benchmark({
name: `Reduce Function Benchmark`,
functions: [
{
name: `Reduce two elements`,
fn: async () => {
[1, 2].reduce((a, b) => a + b);
}
},
{
name: `Reduce three elements`,
fn: async () => {
[1, 2, 3].reduce((a, b) => a + b);
}
}, {
name: `Reduce five elements`,
fn: async () => {
[1, 2, 3, 4, 5].reduce((a, b) => a + b);
}
}
],
options: {
reporters: {
json: {
file: `./dist/reports/benchmark/reduce-benchmark.json`
},
csv: {
file: `./dist/reports/benchmark/reduce-benchmark.csv`
}, html: {
file: `./dist/reports/benchmark/reduce-benchmark.html`
}, htmlTable: {
file: `./dist/reports/benchmark/reduce-benchmark.html`
}
}
}
});
await I.addReporterAttachment({
name: `benchmark`,
mimeType: `text/html`,
path: `./dist/reports/benchmark/reduce-benchmark.html.chart.html`
})