Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-07-28 00:29:03 +0300
committerBen Noordhuis <info@bnoordhuis.nl>2015-07-28 01:13:30 +0300
commit543dabb609226444fae0f9ed10f7b2360b6efda3 (patch)
tree3fda08495f6b2021d5ad481e19bb0b47de8e074e /src/timer_wrap.cc
parent3663b124e6edc6df7c076c28bbc41cdc208f8baa (diff)
timers: improve Timer.now() performance
Record the start time so we can make the return value of Timer.now() relative to it, increasing the chances that it fits in a tagged integer instead of a heap-allocated double, at least for the first one or two billion milliseconds. PR-URL: https://github.com/nodejs/io.js/pull/2256 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/timer_wrap.cc')
-rw-r--r--src/timer_wrap.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc
index 3f2fff1fac2..f3d5d1fedba 100644
--- a/src/timer_wrap.cc
+++ b/src/timer_wrap.cc
@@ -101,6 +101,8 @@ class TimerWrap : public HandleWrap {
Environment* env = Environment::GetCurrent(args);
uv_update_time(env->event_loop());
uint64_t now = uv_now(env->event_loop());
+ CHECK(now >= env->timer_base());
+ now -= env->timer_base();
if (now <= 0xfffffff)
args.GetReturnValue().Set(static_cast<uint32_t>(now));
else