steevej
(Steeve Juneau)
10
Please read 4. Working with the JIT Compiler - Java Performance: The Definitive Guide [Book].
Give more details, how many iterations do you run?
-
Run is insufficient and detrimental to JIT as explained in previous link. You are testing for performance, then execute many time before asserting than one is slower or faster.
-
With same data or different data? Numbers for only 1 data point is insufficient. Especially, if the said data is in cache or note. Numbers with only 1 data point is insufficient because in real life you will have multiple data point. So you have to run multiple iterations with multiple data sets.
-
Do you shutdown the server between your JS and Java test? Having a working set in memory is very important for performance. If you do the java test before js test, then java test is hit by having to fetch data from disk and then js test has no fetch penalty.
You worry too much about the performance difference between java and js because in the end real life performance are influenced more by your schema including indexes and hardware. Both java and js are interpreted. If you think language make such a big difference in a database application, then consider rust, go, c or c++. But remember that the hard work is supposed to be done by the server.
I have doubts about your test setup. I am sure you will come with some corrections like you did for all the other factors I mentioned in my other posts. But that is not the point.
Choose the language you are the most comfortable with and address performance issues when and if they appear. Make it right then make if fast.