mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
timer: change new Date to Date.now for performance
Speeds up benchmark/settimeout.js by about 30%.
This commit is contained in:
1 parent
f210530f46
commit
76104f3414
1 file changed
+4
-4
+4
-4
@@ -51,7 +51,7 @@ var lists = {};
|
||||
// the main function - creates lists on demand and the watchers associated
|
||||
// with them.
|
||||
function insert(item, msecs) {
|
||||
item._idleStart = new Date();
|
||||
item._idleStart = Date.now();
|
||||
item._idleTimeout = msecs;
|
||||
|
||||
if (msecs < 0) return;
|
||||
@@ -71,8 +71,8 @@ function insert(item, msecs) {
|
||||
list.ontimeout = function() {
|
||||
debug('timeout callback ' + msecs);
|
||||
|
||||
var now = new Date();
|
||||
debug('now: ' + now);
|
||||
var now = Date.now();
|
||||
debug('now: ' + (new Date(now)));
|
||||
|
||||
var first;
|
||||
while (first = L.peek(list)) {
|
||||
@@ -155,7 +155,7 @@ exports.active = function(item) {
|
||||
if (!list || L.isEmpty(list)) {
|
||||
insert(item, msecs);
|
||||
} else {
|
||||
item._idleStart = new Date();
|
||||
item._idleStart = Date.now();
|
||||
L.append(list, item);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user