Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Benchmarks

0
0
Hi ravetam!

GlobalMembers is an old Windows script engine feature that we added to V8ScriptEngine for API compatibility. It allows you to expose a host object so that its members (rather than the object itself) appear as global properties within the script environment. Support for this feature is expensive on V8 even when it remains unused, so the only way to avoid the performance hit is to disable it completely.

Now, as for your performance numbers...

V8 executes "Math.random()" extremely quickly; if you move the loop into script code, you'll see that it can run 10,000 iterations in just a couple of milliseconds. In fact, compiling such a script probably makes little or no difference in terms of execution speed. What you're really measuring there is the overhead of invoking V8 via ClearScript vs. JavaScript.NET.

We took a look and were surprised to find that generating a unique script name represents most of ClearScript's overhead. When you compile the script you do this once as opposed to 10,000 times, and that explains the improvement over raw script execution. We'll definitely take a closer look at this.

The remaining difference - approximately twice the invocation overhead for ClearScript vs. JavaScript.NET - is likely due to differences in library design. JavaScript.NET is definitely lighter, and its single-assembly design is an advantage.

Thanks for bringing this to our attention!

Viewing all articles
Browse latest Browse all 2297