According to language benchmarks, JavaScript V8 is faster than other programming languages at regex-dna program. So, why node.js applications (i.e. http server) isn't faster than C applications (i.e. Nginx, Lighttpd)?
Because V8 applications are javascript applications. Even if the javascript is finally compiled to machine code the runtime characteristics are different.
For example if you call a function in an object and that object does not define the function the runtime must locate the function by traversing the prototype hierarchy, this hierarchy can change at any time during the lifetime of a program. There are clever optimizations that can be done but the overhead exists nevertheless.
There is also the memory model. Javascript is garbage collected and GC takes cpu cycles.
Because serving http requests is a different problem than regex-dna.
The fact that A is faster than B at one task doesn't say anything about what to expect from some other task.
Obligatory bad car analogy: A ham sandwich is much tastier than a porsche. Why isn't it faster from 0-60?
For one C is essentially the benchmark language for computation speed. The compliers these days are very good and produce very efficient machine code. What this means is that the upper limit for performance is what you can get with C.
In one of his presentations about node.js Ryan Dahl (the creator) said that node is about as fast as C. (but GC and other things do have an impact on performance, not to mention that V8 needs time to properly optimize things)
In the that benchmark there are 15 different programs and only one dna-regex benchmark where you can see JavaScript V8 is faster. On other benchmarks JavaScript is much lower in performance. You can choose program in the first select, look at this one.
According to language benchmarks, JavaScript V8 is not faster than GCC at binary-trees program.
According to language benchmarks, JavaScript V8 is not faster than GCC at k-nucleotide program.
According to language benchmarks, JavaScript V8 is not faster than GCC at n-body program.
According to language benchmarks, JavaScript V8 is not faster than GCC at spectral-norm program.
According to language benchmarks, JavaScript V8 is not faster than GCC at fasta program.
According to language benchmarks, JavaScript V8 is not faster than GCC at reverse-complement program.
According to language benchmarks, JavaScript V8 is not faster than GCC at pidigits program.
© 2022 - 2024 — McMap. All rights reserved.