nodejs/benchmark/process/bench-hrtime.js
Ruben Bridgewater ed8fc7e11d
tools: update eslint
This updates eslint from v6.0.0-alpha.2 to v6.0.1

This also removes eslint-disable comments about `bigint` typeof
checks. Those would otherwise have caused linting errors now that
`bigint` is accepted as valid entry.

PR-URL: https://github.com/nodejs/node/pull/28173
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-06-27 11:57:19 +02:00

42 lines
837 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const bench = common.createBenchmark(main, {
n: [1e6],
type: ['raw', 'diff', 'bigint']
});
function main({ n, type }) {
const hrtime = process.hrtime;
var noDead = type === 'bigint' ? hrtime.bigint() : hrtime();
var i;
switch (type) {
case 'raw':
bench.start();
for (i = 0; i < n; i++) {
noDead = hrtime();
}
bench.end(n);
break;
case 'diff':
bench.start();
for (i = 0; i < n; i++) {
noDead = hrtime(noDead);
}
bench.end(n);
break;
case 'bigint':
bench.start();
for (i = 0; i < n; i++) {
noDead = hrtime.bigint();
}
bench.end(n);
break;
}
assert.ok(Array.isArray(noDead) || typeof noDead === 'bigint');
}