Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
automatic casting int to boolean casting vs int comparison
(version: 1)
Comparing performance of:
automatic casting vs int comparison
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const array = [] for(let i=0; i<1000; i++){ array.push(Math.random() < 0.5 ? 0 : 1) }
Tests:
automatic casting
let result = 0 for(let i=0;i<array.length;i++){ if(array[i]){ result++ } }
int comparison
let result = 0 for(let i=0;i<array.length;i++){ if(array[i] === 1){ result++ } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
automatic casting
int comparison
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/87.0.0.0
Browser/OS:
Opera 87 on Android
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
automatic casting
77837.3 Ops/sec
int comparison
75093.7 Ops/sec
Comments
Confirm delete:
Do you really want to delete benchmark?