yield vs callback

Benchmark created by AlK on


Preparation HTML

<script type="application/javascript;version=1.7">
function doYield() {
  for (var i = 0; i < 10; i += 1) {
    yield i;
  }
}
</script>
<script type="application/javascript">
function doCallback(cb) {
  for (var i = 0; i < 10; i += 1) {
    cb(i);
  }
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
yield

var result = 0;
for (var j in doYield()) {
  result += j;
}
ready
callback

var result = 0;
doCallback(function(j) {
  result += j;
});
ready

Revisions

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