Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ternary comparison function versus Math.min
(version: 1)
Comparing performance of:
Math.min vs Ternary function
Created:
5 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
this.numberA = Math.random() * 1000; this.numberB = Math.random() * 1000; this.numberC = Math.random() * 1000;
Tests:
Math.min
return Math.min(this.numberA, this.numberB, this.numberC);
Ternary function
if (this.numberA < this.numberB && this.numberA < this.numberC) return this.numberA; if (this.numberB < this.numberA && this.numberB < this.numberC) return this.numberB; return this.numberC;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Math.min
Ternary function
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser/OS:
Firefox 145 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Math.min
28485030.0 Ops/sec
Ternary function
62761628.0 Ops/sec
Related benchmarks:
Math.min vs if/else vs ternary operator
Math.max vs. if vs. ternary
Math.min vs if/else vs ternary operator for Int
Math.min vs if/else vs ternary vs or operator
Math.min vs if/else vs ternary operator vs logical or
Math.max vs. if vs. ternary FIXED
Math.min vs if/else vs ternary operator vs assing first
Math.min vs if/else vs ternary operator test 2
Math.min vs if/else vs ternary operator test 3
Comments
Confirm delete:
Do you really want to delete benchmark?