From b2accb9a49107983f1f6cbbcf6ff8a072f905253 Mon Sep 17 00:00:00 2001 From: David Mandelin Date: Tue, 4 May 2010 18:06:30 -0700 Subject: [PATCH] Bug 563842: Make PRMJ_Now always high-resolution in Windows shell builds, r=brendan --- js/src/prmjtime.cpp | 8 ++++++-- js/src/shell/js.cpp | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/js/src/prmjtime.cpp b/js/src/prmjtime.cpp index 986f480a30be..b9ee16161b6b 100644 --- a/js/src/prmjtime.cpp +++ b/js/src/prmjtime.cpp @@ -407,6 +407,11 @@ def PRMJ_Now(): */ +// We parameterize the delay count just so that shell builds can +// set it to 0 in order to get high-resolution benchmarking. +// 10 seems to be the number of calls to load with a blank homepage. +int CALIBRATION_DELAY_COUNT = 10; + JSInt64 PRMJ_Now(void) { @@ -424,8 +429,7 @@ PRMJ_Now(void) This does not appear to be needed on Vista as the timeBegin/timeEndPeriod calls seem to immediately take effect. */ int thiscall = JS_ATOMIC_INCREMENT(&nCalls); - /* 10 seems to be the number of calls to load with a blank homepage */ - if (thiscall <= 10) { + if (thiscall <= CALIBRATION_DELAY_COUNT) { LowResTime(&ft); return (FILETIME2INT64(ft)-win2un)/10L; } diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 509283a5fdf6..5afeaca3e7d5 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -5010,6 +5010,13 @@ main(int argc, char **argv, char **envp) argc--; argv++; +#ifdef XP_WIN + // Set the timer calibration delay count to 0 so we get high + // resolution right away, which we need for precise benchmarking. + extern int CALIBRATION_DELAY_COUNT; + CALIBRATION_DELAY_COUNT = 0; +#endif + rt = JS_NewRuntime(64L * 1024L * 1024L); if (!rt) return 1;