what is the correct way to calculate the duration of a promise?
const startTm = Date.now();
p1(params).then(
(o)=> {
Log.debug(startTm);
Log.debug(JSON.stringify(o));
return o;
});
const runTm = Date.now() - startTm;
The startTm is invisible inside then().
UPDATE:
my bad. startTm is visible. So is there any other ways?
const startTm = Date.now();
p1(params).then((o)=> {
output = o
console.log(startTm);
Log.debug(JSON.stringify(o));
let runTm = Date.now() - startTm;
Log.debug('duration: ' + runTm + 'ms');
return o;
});