Issues (19)

helpers/benchmark/benchmarks-fallback.test.js (1 issue)

1
// import path from 'path';
2 View Code Duplication
import { assert } from 'chai';
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
3
import { load, sleep } from '../../Test';
4
5
const benchmarkPath = 'benchmark.js';
6
const hrtime = process.hrtime;
7
const performance = global.performance;
8
9
let getBenchmark;
10
11
let  startBenchmark;
12
13
suite('Fallback benchmarks');
14
15
before(function () {
16
    process.hrtime = 0;
17
    global.performance = null;
18
19
    const fallback = load(benchmarkPath, true);
20
21
    getBenchmark = fallback.getBenchmark;
22
    startBenchmark = fallback.startBenchmark;
23
});
24
25
test('Positive: min measurable time', function () {
26
    const time = startBenchmark();
27
    const benchmark = getBenchmark(time);
28
29
    assert.isString(benchmark);
30
    assert.isNumber(+benchmark);
31
});
32
33
test('Positive: measure time', async function () {
34
    const time = startBenchmark();
35
36
    await sleep(20);
37
    const benchmark = getBenchmark(time);
38
39
    assert.isString(benchmark);
40
    assert.isAtLeast(+benchmark, 19);
41
});
42
43
after(async function () {
44
    process.hrtime = hrtime;
45
    global.performance = performance;
46
});
47