Boolean->Int

Benchmark created by Qix on


Description

Checks the speed of boolean->integer operations

Setup

var b = Math.floor(Math.random()*2) === 1;

Test runner

Ready to run.

Testing in
TestOps/sec
Ternary Operator, implicit
var i = b ? 1 : 0;
ready
Ternary Operator, explicit
var i = b === true ? 1 : 0;
ready
Auto-box Conversion (+ operator)
var i = +b;
ready

Revisions

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