If you are following ReactJS.NET topic, then you probably know that they are migrated to a new JS engine. Now the project is using JavaScript Engine Switcher, which supports multiple engines: MSIE, V8, Jint, Jurassic, Chakra Core & Vroom. As I’m planning to use JS engine to render components we need to know which one is the best.

Test Setup

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.

https://gist.github.com/asmagin/61828052d8da96bc0e4497e83e96299f

Results

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 EngineInitialization, sExecution time for 1k, sMax Memory used, ~MB
Jint4.5753.52450
MSIE Auto1.556.62280
ClearScript V82.666.94190 *
ChakraCore1.605.58 *260
Vroom1.46 *7.55360

And also scores:

JS EngineInitializationExecution time for 1kMax Memory used
Jint3.129.592.37
MSIE Auto1.061.191.47
ClearScript V81.821.241.00 *
ChakraCore1.091.00 *1.37
Vroom1.00 *1.351.89

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.

Summary

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.