0

I have this function

const performance = require('perf_hooks');

var t0 = performance.now();

setInterval(printStatus, 20000);

function printStatus() {

     console.log(
    `Total records: ${count}`
  );
  console.log("Time elapsed" + (performance.now() - t0)/60000 + "minutes")
}

This prints minutes like this: Time elapsed0.3334145895500978minutes

I want it to become human readable HH:MM:S How do I make it happen?

Amna Arshad
  • 767
  • 3
  • 10
  • 21

1 Answers1

0

I would do this:

const performance = require('perf_hooks');

var t0 = performance.now();

setInterval(printStatus, 20000);

function printStatus() {

     console.log(
    `Total records: ${count}`
  );
  const msElapsed = (performance.now() - t0);
  const hhmmss = (new Date(msElapsed)).toISOString().substr(11,8);
  console.log("Time elapsed " + hhmmss )
}
gonzalo
  • 377
  • 2
  • 9