Earlier quoted context omitted.
How fast is a hello world in node.js to you? I forgot to mention my formerly favorite language: Python. It's _much_ faster than Node.js in startup and relatively basic things. Node wins on almost everything I make, though. $ time python test.py # second run hello world real 0m0.009s user 0m0.009s sys 0m0.000s
Best times from a few "do nothing" runs of Node: $ time node -e '' real 0m0.098s user 0m0.084s sys 0m0.010s Of course on my desktop it's a $ time node -e '' real 0m0.002s user 0m0.000s sys 0m0.000s tiny bit different. Python on my laptop is just slow enough that I really notice it: $ time python -c '' real 0m0.032s user 0m0.022s sys 0m0.009s Of course PHP is all 0.014, 0.010, 0.012, etc. Incidentally, this T43 is a b…
// watch.js
var file = process.argv[2]
console.log('press enter to run '+file)
process.stdin.on('data', function(){
var [s1,ns1] = process.hrtime()
for(var k in require.cache) {
delete require.cache[k]
}
require(file)
var [s2,ns2] = process.hrtime()
var s = (s2-s1)+(ns2-ns1)*1e-9
console.log('time: ' + s.toFixed(9))
})
Result: less than 1ms on first run $ node watch.js ./test.js
press enter to run ./test.js
hello world
time: 0.000952656
hello world
time: 0.000284171
edit: script now deletes all cache, not only the passed script (result is the same if the script doesn't require others)