Scope speed test with global eval and functions

Benchmark created by Alexander Korzhikov on


Description

Why would we use eval global scope options? When do we need it? Going up by scopes we get value much faster...

First example for moving up by scopes, second with eval.

Preparation HTML

<script>
  var num = 200,
      foo = 123,
      i = 0;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
functions
(function() {
 if (i++ < num) {
  arguments.callee()
 }
 else {
  foo = 456;
 }
})()
ready
eval
(function() {
 if (i++ < num) {
  arguments.callee()
 }
 else {
  var e = eval;
  e('var foo = 456')
 }
})()
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Alexander Korzhikov on