Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36
Chrome 91
Windows
Desktop
3 years ago
Test name Executions per second
Math.min/max 2419236.0 Ops/sec
Ternary 3976395.0 Ops/sec
Math.min 4122107.0 Ops/sec
Ternary min 5335585.0 Ops/sec
Math.max 4131418.0 Ops/sec
Ternary max 5381275.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