You can get a rough idea of VM startup time by running a simple hello world program.
fdir is supposed to compete against nodejs alternatives so I am not surprised it comes last. Maybe the next goal should be to optimize it against other cross language platforms.
V8 does a lot of optimizations but there is still overhead. A native solution in bash has little to no overhead so no wonder it's the fastest.
Anyway, thanks again. This benchmark was insightful (also humbling).
So basically:
83ms - 55ms = 28ms
Not bad, not bad. :D the scale remains the same tho so not that beneficial.
2) v8 doesn't make your code blazing fast by default. It has many optimizations but your code may be written in a way that v8 cannot fully optimize.
3) I recommend this tool as an alternative to using "time": https://github.com/sharkdp/hyperfine
So this is not a benchmark. Just a fun observation of a trend. A proper benchmark would require to have a dedicated machine with no other softwares running, hyperthreading off and run each of them a 100 times, without fs cache.
EDIT: gonna edit the original post with hyperfine results.
They all list all files recursively in a sync fashion, from the node_modules dir (like in the benchmark), excluding dirs, and print a total count.
Here are the results calculated with hyperfine (https://github.com/sharkdp/hyperfine):
Here are the results of an hello world with each runtime for comparison: Now, my machine is not setup for a clean benchmark. The disk cache is warmed up. Hyperthreading is on. Other softwares are running.Plus the scripts all found a slightly different number of files :) I suspect they all treat symlinks/dotted dirs differently, and I didn't take the time to normalize. Although I don't think this makes up for the difference.
Still the result is a bit interesting. The non JS tests are not using any 3rd party libs. Ruby and Node seems to have the same cost for VM startup.
I'm quite surprised that node is last frankly, especially on a uber optimized code. I'm expecting V8 code to be blazing fast as it's Google made and C++.