Coercion vs Casting (v2)

Revision 2 of this benchmark created by Fedor Indutny on


Description

Which is faster, which is sexier? I vote coercion!

Preparation HTML

<script>
  var floor = Math.floor;
  var parseI = parseInt;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Coercion
~~+'2.9'-1
ready
Casting
Math.floor(parseInt('2.9') - 1)
ready
Casting (Cached) #1
floor(parseInt('2.9') - 1)
ready
Casting (Cached) #2
floor(parseI('2.9') - 1)
ready

Revisions

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