Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36 Edg/93.0.961.47
Chrome 93
Windows
Desktop
3 years ago
Test name Executions per second
Math.min/max 2980730.0 Ops/sec
Math.min 5031812.0 Ops/sec
Math.max 5171800.0 Ops/sec
Ternary clamp 4687467.0 Ops/sec
Ternary min 6024971.0 Ops/sec
Ternary max 6268242.0 Ops/sec
Ternary clamp inlined 6281729.0 Ops/sec
Ternary min inlined 6278114.0 Ops/sec
Ternary max inlined 6204690.0 Ops/sec
Script Preparation code:
Tests:
  • Math.min/max

  • Math.min

  • Math.max

  • Ternary clamp

  • Ternary min

  • Ternary max

  • Ternary clamp inlined

  • Ternary min inlined

  • Ternary max inlined