eval kills

JavaScript performance comparison

Test case created by John-David Dalton and last updated

Preparation code

<script>
setTimeout(function() {
  ui.benchmarks[0].options.setup = 'eval("var str=\'hello world\'")';
}, 0);
</script>
<script>
Benchmark.prototype.setup = function() {
    var str = 'hello world';
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
with eval
r = str.charAt() + str.slice(1);
pending…
without eval
r = str.charAt() + str.slice(1);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

1 comment

John-David Dalton (revision owner) commented :

The point of this test is to show that simply using eval still disables engine optimizations for the method but may not be a perf problem in average use.

Add a comment