The first version of this post is there.
I was looking for a JavaScript run time that I could embed in my C# applications. I have done that in the past with IronPython. I tried different implementations written in C# and then I decided to try all executables on my Windows XP machine that could run JavaScript from a command prompt.
All tests were executed on my Windows XP Dell Inspiron 6400.
There are the modules I used from the benchmark:
- Richards
- DeltaBlue
- Crypto
- RayTrace
- RegExp
- Splay
Final Scores
About the score: bigger is better! JavaScript Engine Score ------------------------------------------------------------- NodeJs 0.4.6 V8 4148 Noesis 0.4 V8 + x86 NET 4.0 2454 PhantomJs 1.1.0 JavaScriptCore - JIT compiler 1688 IronJS 0.2 x86 .NET 4.0 62 Jurassic 2.1 x86 .NET 3.5 51 Microsoft Jscript 5.7 40 Jint x86 .NET 3.5 killed after one hour JSDB 10.6.21.0 SpiderMonkey out of memory - Execution error nodeJs 0.4.6 - V8 =================================== Start...Thu Jun 23 2011 02:18:08 GMT+0000 (EST) Crypto: 4906 DeltaBlue: 7980 RayTrace: 6720 RegExp: 1707 Richards: 5175 Splay: 2192 ---- Score (version 6): 4148 Duration:15.506 Noesis.Javascript 0.4 - V8 + x86 .NET 4.0 =================================== Start...Wed Jun 22 2011 22:32:57 GMT-0400 (Eastern Daylight Time) Crypto: 3604 DeltaBlue: 3937 RayTrace: 3763 RegExp: 1180 Richards: 3195 Splay: 1084 ---- Score (version 6): 2454 Duration:17.067 This is an older version of V8 and this is why it is slower than nodejs. PhantomJs v1.1.0 - JavaScriptCore with JIT compiler =================================== Start...Wed Jun 22 2011 22:29:25 GMT-0400 (Eastern Daylight Time) Duration:0 Crypto: 2278 DeltaBlue: 1514 RayTrace: 2617 RegExp: 559 Richards: 2017 Splay: 2269 ---- Score (version 6): 1688 Jurassic v2.1 - .NET Implementation x86 v 3.5 =================================== Start...Wed Jun 22 2011 22:18:30 GMT-0400 (Eastern Daylight Time) Crypto: 57.7 DeltaBlue: 54.4 RayTrace: 29.9 RegExp: 33.8 Richards: 66.0 Splay: 86.5 ---- Score (version 6): 51.3 Duration:263.796875 http://jurassic.codeplex.com IronJS v0.2 - .NET Implementation x86 v 4.0 =================================== Start...Wed, 22 Jun 2011 22:34:25 GMT-04:00 Crypto: 83.23 DeltaBlue: 61.34 RayTrace: 20.01 RegExp: 38.03 Richards: 74.74 Splay: 201 ---- Score (version 6): 62.26 Duration:275.141 Still not bad for an implementation written by one person. http://ironjs.wordpress.com JSDB - 10.6.21.0 - Mozilla SpiderMonkey =================================== Start...Wed Jun 22 2011 23:08:51 GMT-0400 (Eastern Daylight Time) Crypto: 142 DeltaBlue: 155 RayTrace: 110 RegExp: 126 Richards: 161 out of memory - Execution error in C:\FredericTorres.Net.Src\JS\Benchmark\all.js. http://www.jsdb.org Microsoft JScript 5.7 =================================== Start...Wed Jun 22 22:23:17 EDT 2011 Crypto: 80.8 DeltaBlue: 44.5 RayTrace: 62.7 RegExp: 91.4 Richards: 44.3 Splay: 4.75 ---- Score (version 6): 40.4 Duration:194.328 Jint - JavaScript Runtime:.NET Implementation x86 v 3.5 =================================== After one hour I killed the program. http://jint.codeplex.com
JavaScript Runtimes
Here we have 4 choices, Jint does not use the DLR and you can tell. IronJS and Jurassic are very close.
I had some bizarre issues with compiling my IronJS solution (I had to rebuild my solution to see my changes). Anyway it is difficult to beat Noesis.Javascript which use V8.
I started writing some C# code to be able to write and read JavaScript objects from/to Noesis JavaScript.net context object using the dynamic feature of .NET 4.0. I will be blogging about this in the future. The code looks like this:
There is another solution Microsoft JScript.NET, the JScript that came with .NET and that nobody is using. I will have to try.
I had some bizarre issues with compiling my IronJS solution (I had to rebuild my solution to see my changes). Anyway it is difficult to beat Noesis.Javascript which use V8.
I started writing some C# code to be able to write and read JavaScript objects from/to Noesis JavaScript.net context object using the dynamic feature of .NET 4.0. I will be blogging about this in the future. The code looks like this:
dynamic jsContext = new DynamicJavascriptContext(new JavascriptContext()); jsContext.message = "Hello World !"; jsContext.number = 1; jsContext.array = DS.List(1, 2 , 3); jsContext.instance = DS.Dictionary( new { b = 2 } ); jsContext.instance2 = DS.Dictionary( new { a = 1, b = 2 } ); string script = @" number = 123; instance['a'] = 1; instance['Date'] = new Date(); instance2['a'] = 123; console.log('Hello log '); console.log('array.length:'+array.length); array.push(4); for(var i=0; i<array.length; i++) console.log(array[i]); "; jsContext.Run(script); Console.WriteLine("number: " + jsContext.number ); Console.WriteLine("instance: " + jsContext.instance ); Console.WriteLine("instance.a: " + jsContext.instance.a ); Console.WriteLine("instance.b: " + jsContext.instance.b ); Console.WriteLine("instance.Date: " + jsContext.instance.Date); Console.WriteLine("instance2.a: " + jsContext.instance2.a ); Console.WriteLine("array:" + jsContext.array.Length ); Console.WriteLine("array[3]:" + jsContext.array[3] );
There is another solution Microsoft JScript.NET, the JScript that came with .NET and that nobody is using. I will have to try.
This is a smart blog. I mean it. You have so much knowledge about this, and so much passion. You also know how to make people rally behind it, obviously from the responses. wordpress developers for hire
ReplyDelete