3

I need to run some benchmark tests on different JS engines, need to measure timing, CPU and memory usage. I'd like to run my tests from the commandline. Found some solutions for V8 and SpiderMonkey, is there some way to do this with Chakra?

codercube
  • 31
  • 3
  • Possible duplicate: http://stackoverflow.com/questions/5429749/c-sharp-ie9-js-engine-chakra – JayC Mar 31 '13 at 19:29
  • In short, it seems the answer is "yes". See also http://stackoverflow.com/questions/5939002/will-the-ie10-chakra-jscript-engine-available-as-stand-alone-accessible-from-c/7367964#7367964 – JayC Mar 31 '13 at 19:29

2 Answers2

2

There is no officially supported way to run the IE9 or IE10 Chakra engines standalone. As of IE11, there is a Win32 API: http://www.panopticoncentral.net/2013/07/02/introducing-jsrt-embedding-javascript-on-windows/.

panopticoncentral
  • 1,753
  • 11
  • 22
0

You can do it using mshtml.dll. Make a command line application in C# and reference the COM component "Microsoft HTML Object Library". Then create a new document and navigate to an html file that has this meta tag in the header:

<META content="IE=X" http-equiv="X-UA-Compatible">

Where the X in IE=X is the version of IE that you want. This will tell mshtml to create the appropriate version of the jscript engine and your script will be executed by that engine. If you use IE=11, it will use chakra, anything older than 10 I believe will be jscript.

You can use the standard mshtml classes to execute script and interact with the javascript runtime.

justin.m.chase
  • 11,241
  • 6
  • 42
  • 84