|
@ -1,5 +1,3 @@ |
|
|
const { performance } = require('perf_hooks'); |
|
|
|
|
|
|
|
|
|
|
|
const { isPromise } = require('../util'); |
|
|
const { isPromise } = require('../util'); |
|
|
|
|
|
|
|
|
const caller = (test, state) => { |
|
|
const caller = (test, state) => { |
|
@ -8,11 +6,11 @@ const caller = (test, state) => { |
|
|
|
|
|
|
|
|
let value, error, errored; |
|
|
let value, error, errored; |
|
|
try { |
|
|
try { |
|
|
perf.start = performance.now(); |
|
|
perf.start = Date.now(); |
|
|
value = test(state); |
|
|
value = test(state); |
|
|
perf.end = performance.now(); |
|
|
perf.end = Date.now(); |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
|
perf.end = performance.now(); |
|
|
perf.end = Date.now(); |
|
|
errored = true; |
|
|
errored = true; |
|
|
error = e; |
|
|
error = e; |
|
|
} |
|
|
} |
|
@ -22,13 +20,13 @@ const caller = (test, state) => { |
|
|
if (promise) { |
|
|
if (promise) { |
|
|
return value |
|
|
return value |
|
|
.then(res => ({ |
|
|
.then(res => ({ |
|
|
duration: performance.now() - perf.start, |
|
|
duration: Date.now() - perf.start, |
|
|
status: 'ok', |
|
|
status: 'ok', |
|
|
resolve: res, |
|
|
resolve: res, |
|
|
promise: true |
|
|
promise: true |
|
|
})) |
|
|
})) |
|
|
.catch(rej => ({ |
|
|
.catch(rej => ({ |
|
|
duration: performance.now() - perf.start, |
|
|
duration: Date.now() - perf.start, |
|
|
status: 'notOk', |
|
|
status: 'notOk', |
|
|
rejection: rej, |
|
|
rejection: rej, |
|
|
promise: true |
|
|
promise: true |
|
|