Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Conversation

@robertkowalski
Copy link

As we are going to need fs in any case, just require it at the
beginning of the file.

As we are going to need fs in any case, just require it at the
beginning of the file.
@indutny
Copy link
Member

indutny commented Jul 3, 2014

Does it have any implication on startup time? When starting repl?

@robertkowalski
Copy link
Author

happy to confirm that it has :)

as far as I can measure it with these micro benchmarks ...

Before each test I rebooted the machine, and waited 30sec. Order from up to down - was running the upper ones first.

Used https://github.com/robertkowalski/require-benchmark - I am happy if I get some help to get the benchmarks running with dtrace.

Not sure about the first Hapi Webserver run, it is slower. But after a final reboot after all of the first tests ran I got a significally better result (maybe caching between the reboot?):

(00:21:03) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark hapi
node: 1354ms
node: 789ms
node: 787ms
node: 788ms
node: 783ms
node: 782ms
node: 785ms
node: 807ms
node: 849ms
node: 798ms
node: 788ms

Total time:   9310 ms
Average time: 931 ms

Results

changed

Hapi Webserver

(00:00:46) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark hapi
node: 2178ms
node: 791ms
node: 784ms
node: 798ms
node: 789ms
node: 781ms
node: 783ms
node: 784ms
node: 794ms
node: 775ms
node: 783ms

Total time:   10040 ms
Average time: 1004 ms

flat.js

(00:04:36) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark flat
node: 12262ms
node: 5268ms
node: 5090ms
node: 4947ms
node: 5105ms
node: 4993ms
node: 5061ms
node: 5048ms
node: 5075ms
node: 4991ms
node: 5122ms

Total time:   62962 ms
Average time: 6296 ms

current master

Hapi Webserver

(00:08:40) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark hapi
node: 1361ms
node: 822ms
node: 828ms
node: 830ms
node: 833ms
node: 831ms
node: 837ms
node: 856ms
node: 818ms
node: 850ms
node: 859ms

Total time:   9725 ms
Average time: 972 ms

flat.js

(00:11:15) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark flat
node: 15345ms
node: 5006ms
node: 4988ms
node: 5038ms
node: 4984ms
node: 5032ms
node: 5106ms
node: 5164ms
node: 5054ms
node: 4960ms
node: 4972ms

Total time:   65649 ms
Average time: 6564 ms

@indutny
Copy link
Member

indutny commented Jul 3, 2014

Gosh, how I hate mixed results :) So what's your final opinion on it?

@robertkowalski
Copy link
Author

For me the multiple requires distracted me while reading the code and that was my initial intend for removing them just with the assumption that it would not increase or decrease the performance.

After I got some sleep I would like to make a second testrun for the benchmarks, for me it looks like the initial hapi test value was a freak value. Also because it was faster after the intitial first testset.

@robertkowalski
Copy link
Author

This time I cold booted the machine before each test, and waited
30sec. Opened the Terminal at the beginning of the first 30sec.

This time I disabled all startup programs and the indexing of the
window manager, plus WiFi. (I'm ashamed that I didn't do
that yesterday)

Some day I will buy a dedicated Linux machine for
this, that just has a minimal Linux installation with no GUI just
for these kinds of test. But currently I don't have access to such a
machine. People who have (maybe you) can feel to reproduce the tests
using the repo that I used (https://github.com/robertkowalski/require-benchmark)

For me it looks like the new implementation is slighty faster, which makes sense to me

changed

Hapi Webserver

(20:00:03) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark hapi
node: 1342ms
node: 779ms
node: 784ms
node: 804ms
node: 781ms
node: 781ms
node: 805ms
node: 769ms
node: 774ms
node: 775ms
node: 788ms

Total time:   9182 ms
Average time: 918 ms

flat.js

(20:02:06) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark flat
node: 11358ms
node: 5045ms
node: 5146ms
node: 5610ms
node: 5222ms
node: 5070ms
node: 5061ms
node: 5076ms
node: 4926ms
node: 5073ms
node: 5131ms

Total time:   62718 ms
Average time: 6271 ms

current master

Hapi Webserver

(20:05:16) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark hapi
node: 1393ms
node: 806ms
node: 773ms
node: 807ms
node: 825ms
node: 803ms
node: 790ms
node: 813ms
node: 780ms
node: 816ms
node: 812ms

Total time:   9418 ms
Average time: 941 ms

flat.js

(20:08:19) [robert@tequila-osx] ~/require-benchmark (master *) $ ./run-benchmark flat
node: 17889ms
node: 5183ms
node: 4893ms
node: 4984ms
node: 4955ms
node: 4985ms
node: 4911ms
node: 5018ms
node: 4963ms
node: 5032ms
node: 4997ms

Total time:   67810 ms
Average time: 6781 ms

@indutny
Copy link
Member

indutny commented Jul 7, 2014

Ok, let's land it!

@indutny
Copy link
Member

indutny commented Jul 7, 2014

Landed in 46ccb20

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants