bench.js 401 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const internals = {};
  3. module.exports = internals.Bench = class {
  4. constructor() {
  5. this.ts = 0;
  6. this.reset();
  7. }
  8. reset() {
  9. this.ts = internals.Bench.now();
  10. }
  11. elapsed() {
  12. return internals.Bench.now() - this.ts;
  13. }
  14. static now() {
  15. const ts = process.hrtime();
  16. return (ts[0] * 1e3) + (ts[1] / 1e6);
  17. }
  18. };