var moment = require('moment-timezone');
var _timeConsumingFunc = () => {
// wait a few seconds
for (i = 0; i < 1000000000; i++) {
// do nothing
}
}
var _promiseChainFunc = () => {
var start = moment.tz('Europe/London');
return Promise.resolve()
.then(() => {
return _timeConsumingFunc();
})
.then(() => {
const duration = moment.tz('Europe/London').diff(start, 'seconds', true);
console.log(`The elapsed time: ${duration}`);
});
};
_promiseChainFunc();
Created
August 30, 2017 14:24
-
-
Save tappoz/74b8d6df7155ffb7b1862f8d0bc9e1aa to your computer and use it in GitHub Desktop.
Javascript / Node.js tricks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment