Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Chrome 91
Windows
Desktop
3 years ago
Test name Executions per second
Math.min/max 2274186.2 Ops/sec
Math.min 4049675.8 Ops/sec
Math.max 4027030.5 Ops/sec
Ternary clamp 4246420.5 Ops/sec
Ternary min 5703081.0 Ops/sec
Ternary max 5733434.5 Ops/sec
Ternary clamp inlined 3409080.5 Ops/sec
Ternary min inlined 5721079.0 Ops/sec
Ternary max inlined 5709715.5 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