Browse Source

[test-recorder] Fixes to getting correct time

master
Muthu Kumar 6 years ago
parent
commit
b5ab09095d
  1. 10
      src/lib/caller.js
  2. 4
      src/lib/testrunner.js
  3. 4
      src/runner/index.js
  4. 7
      src/util/nodeutils.js

10
src/lib/caller.js

@ -6,11 +6,11 @@ const caller = (test, state) => {
let value, error, errored;
try {
perf.start = Date.now();
perf.start = new Date();
value = test(state);
perf.end = Date.now();
perf.end = new Date();
} catch (e) {
perf.end = Date.now();
perf.end = new Date();
errored = true;
error = e;
}
@ -20,13 +20,13 @@ const caller = (test, state) => {
if (promise) {
return value
.then(res => ({
duration: Date.now() - perf.start,
duration: new Date() - perf.start,
status: 'ok',
resolve: res,
promise: true
}))
.catch(rej => ({
duration: Date.now() - perf.start,
duration: new Date() - perf.start,
status: 'notOk',
rejection: rej,
promise: true

4
src/lib/testrunner.js

@ -122,14 +122,14 @@ const reduceQueue =
*/
const testrunner = (instance) => {
const perf = { start: Date.now() };
const perf = { start: new Date() };
return Promise.object(pipe(
buildTestQueue,
reduceQueue,
pick('results'),
)(instance)).then(results => {
perf.end = Date.now();
perf.end = new Date();
results.end = perf.end.toUTCString();
results.start = perf.start.toUTCString();
results.duration = perf.end - perf.start;

4
src/runner/index.js

@ -26,7 +26,7 @@ const runner = instances => (options = {}) => {
if (RunInstances.length !== instances.length)
throw new Error (`Not all instances were of type ${type}`);
const perf = { start: Date.now() };
const perf = { start: new Date() };
return Promise.all(RunInstances.map(instance => {
return (
@ -35,7 +35,7 @@ const runner = instances => (options = {}) => {
);
}))
.then(results => {
perf.end = Date.now();
perf.end = new Date();
results.start = perf.start.toUTCString();
results.end = perf.end.toUTCString();
results.duration = perf.end - perf.start;

7
src/util/nodeutils.js

@ -2,6 +2,13 @@ module.exports = {
clear: () => {
if (typeof global === 'undefined'
|| typeof global.process === 'undefined'
|| typeof global.process.stdout === 'undefined'
) return;
const process = global.process;
// clear screen
process.stdout.write('\u001b[2J');
// set cursor position to top

Loading…
Cancel
Save