aboutsummaryrefslogtreecommitdiff
path: root/src/timer_wrap.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-07-27 23:29:03 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2015-07-28 00:13:30 +0200
commit543dabb609226444fae0f9ed10f7b2360b6efda3 (patch)
tree3fda08495f6b2021d5ad481e19bb0b47de8e074e /src/timer_wrap.cc
parent3663b124e6edc6df7c076c28bbc41cdc208f8baa (diff)
downloadandroid-node-v8-543dabb609226444fae0f9ed10f7b2360b6efda3.tar.gz
android-node-v8-543dabb609226444fae0f9ed10f7b2360b6efda3.tar.bz2
android-node-v8-543dabb609226444fae0f9ed10f7b2360b6efda3.zip
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 3f2fff1fac..f3d5d1fedb 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