提交 c337d8be 编写于 作者: B Ben Houston

use new Date().getTime() when not in a node.js environment.

上级 3b8609e1
......@@ -9,13 +9,28 @@ if( window.performance === undefined ) {
}
if( ( window.performance.now === undefined ) && ( process !== undefined ) && ( process.hrtime !== undefined ) ) {
if( window.performance.now === undefined ) {
window.performance.now = function () {
// check if we are in a Node.js environment
if( ( process !== undefined ) && ( process.hrtime !== undefined ) ) {
var time = process.hrtime();
return ( time[0] + time[1] / 1e9 ) * 1000;
window.performance.now = function () {
};
var time = process.hrtime();
return ( time[0] + time[1] / 1e9 ) * 1000;
};
}
// if not Node.js revert to using the Date class
else {
window.performance.now = function() {
return new Date().getTime();
};
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册