Lately I was trying to understand
how virtual memory works
and how JVM work and perform.
My intuition was ' if a JVM is written in C, it is probably less performant than C '
So after a lot of reading and investigations I found out that the story is much more complicated then I have initially thought.
JVM has many optimization which makes it very fast most of the time, it does has an overhead but the optimization in JIT make everything worth it.
basically the JVM will loaded into native virtual memory (and be shared with other processes when possible)
it will use sophisticated algorithms to allocate memory on the native heap to create managed heap.
it will JIT to perform well, will vectorise actions and what not to make the run time overhead worth it.
At that point I was thinking ' OK, so javascript is a VM, it should probably also perform well '
But benchmark tests online showed different things. I know javascript is single threaded but this tests take this into account (For example fork many process).
The V8 engine is highly optimized and make all kind of clever things to perform faster, for example making a behind the scene classes and types and caches to speed up the execution.
V8 is still young compared to C and Java so I am sure it will be even better. my impression is that optimizing a dynamic language such as javascript is harder than a language like java, but I might be wrong here.
Any way I thought that I have to make my own test to better understand the performance difference in various situations, so here it is, my results
- Java和节点在执行循环和在内存中时获胜c并从文件读取到磁盘的胜利开始Java在http服务器中获胜
希望您会发现此信息对您有帮助!
评论更受欢迎。
我也有一个博客,里面有其他有趣的东西: