You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
669 B
27 lines
669 B
2 years ago
|
var now = require('./now');
|
||
|
var root = require('./root');
|
||
|
var performance = root.performance;
|
||
|
var process = root.process;
|
||
|
var loadTime;
|
||
|
if (performance && performance.now) {
|
||
|
exports = function() {
|
||
|
return performance.now();
|
||
|
};
|
||
|
} else if (process && process.hrtime) {
|
||
|
var getNanoSeconds = function() {
|
||
|
var hr = process.hrtime();
|
||
|
return hr[0] * 1e9 + hr[1];
|
||
|
};
|
||
|
loadTime = getNanoSeconds() - process.uptime() * 1e9;
|
||
|
exports = function() {
|
||
|
return (getNanoSeconds() - loadTime) / 1e6;
|
||
|
};
|
||
|
} else {
|
||
|
loadTime = now();
|
||
|
exports = function() {
|
||
|
return now() - loadTime;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
module.exports = exports;
|