For the test, I’m not going to use everything in ReactJS.NET but only JSPool and everything below.
I’m running it on my laptop with the following configurations:
- Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
- 16.GB RAM
- Windows 10 Home 64-bit
- 512 GB SSD
For each engine, I would 10 cycles initialization and procession of 1000 commands. As A command I’ve selected a server-side rendering of a header component used in previous posts. The component is generated as a part of a WebPack package that includes React & Redux. The size of the package is ~2MB.
To start with I need to mention that not all engines were able to finish. Jurassic start throwing errors and was abandoned.
Here is a timing for each tested engine:
|JS Engine||Initialization, s||Execution time for 1k, s||Max Memory used, ~MB|
|ClearScript V8||2.66||6.94||190 *|
And also scores:
|JS Engine||Initialization||Execution time for 1k||Max Memory used|
|ClearScript V8||1.82||1.24||1.00 *|
In the tables above you can see that engines except Jint are doing a good job. Vroom and ClearScript V8 both have Google V8 under the hood and execution time seems to be
Vroom and ClearScript V8 both have Google V8 under the hood and execution time seems to be similar as well. However, ClearScript does a better job in memory management.
MSIE and ChakraCore are pretty much the same engines as well but called differently. MSIE expects that you will have IE installed and goes through it, while Chakra Core is MS new JS engine itself. That is explaining overhead in the execution of scripts. (Did you know that CC is cross-platform and there is a CC version of NodeJS?)
Finally, based on all three params in the test, I declare CC a winner. Second place goes to ClearScript V8.
ClearScriptV8 and ChakraCore are 2 solid candidates to be used in Sitecore to integrate it with JS. Based on all three params in the test, I declare CC a winner :)
As a side effect of this test, I thought that for Sitecore we don’t need everything in the ReactJS.NET module. I’ve overridden and replaced a lot over there already. We could just create JSPool with CC Engine in Sitecore initialization pipeline and extend Sitecore controller with wrappers to render methods. That is what I’m planning to do next.
Follow me on Twitter @true_shoorik. Would be glad to discuss the ideas above in the comments.