eval or func

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var input = 'Math.sin(x)';
};
</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
eval
for (var x=0; x<10000; x++) {
   var y = eval(input);
}
pending…
func
var f = Function('x','return '+input);
for (var x=0; x<10000; x++) {
   var y = f(x);
}
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:

0 comments

Add a comment