I disagree to re-implement Date.now() within Node because it is defined
in ES5 and V8 should take care of its performance.
In timer case, there is an alternative to use process.hrtime() instead
of Date.now(). I've just made a quick hack to use it in
https://github.com/shigeki/node/compare/test_hrtime
for benchmark.
I tested http_simple_bench.sh but there seems no significant difference
as below.
./benchmark/http_simple_bench.sh with Date.now() in timer
ab-hello-world-buffer-102400 Requests per second: 1548.97 [#/sec]
ab-hello-world-buffer-1024 Requests per second: 1755.29 [#/sec]
ab-hello-world-string-102400 Requests per second: 459.39 [#/sec]
ab-hello-world-string-1024 Requests per second: 1919.99 [#/sec]
./benchmark/http_simple_bench.sh with process.hrtime() in timer
ab-hello-world-buffer-102400 Requests per second: 1491.16 [#/sec]
ab-hello-world-buffer-1024 Requests per second: 1748.89 [#/sec]
ab-hello-world-string-102400 Requests per second: 612.75 [#/sec]
ab-hello-world-string-1024 Requests per second: 1953.58 [#/sec]
(2012/10/26 16:38), Alexey Kupershtokh wrote:
> Ok then.
>
> cp benchmark/http_simple_auto.js benchmark/http_simple_auto2.js
> edit benchmark/http_simple_auto2.js and add this code at the start:
> var n = 1000;
> var now = Date.now();
> Date.now = function() {
> if (n-- == 0) {
> n = 1000;
> now = Date.now();
> }
> return now;
> }
>
> Make sure you have a version that already uses Date.now() in timers.js
> instead of new Date();
>
> RPS for the benchmarks in a few runs in turn, sorted by asc:
> benchmark/http_simple_auto.js: 15635, 15739, 16025, 16076, 16091; avg
> = 15913
> benchmark/http_simple_auto2.js: 16402, 16735, 16783, 16815, 16881; avg
> = 16723
> 16723 / 15913 = 1.051
> So the http_simple_auto2.js is overall 5% faster just because of
> speeding up Date.now().
>
> О©╫О©╫О©╫О©╫О©╫О©╫О©╫, 26 О©╫О©╫О©╫О©╫О©╫О©╫О©╫ 2012 О©╫., 10:51:15 UTC+7 О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫О©╫ Ben Noordhuis
> О©╫О©╫О©╫О©╫О©╫О©╫О©╫:
> --
> Job Board:
http://jobs.nodejs.org/
> Posting guidelines:
>
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to
nod...@googlegroups.com
> To unsubscribe from this group, send email to
>
nodejs+un...@googlegroups.com
> For more options, visit this group at
>
http://groups.google.com/group/nodejs?hl=en?hl=en