Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Chrome 93
Windows
Desktop
3 years ago
Test name Executions per second
Math.min/max 2820374.2 Ops/sec
Math.min 4849891.0 Ops/sec
Math.max 4886591.5 Ops/sec
Ternary clamp 4533224.5 Ops/sec
Ternary min 6113265.5 Ops/sec
Ternary max 6119923.5 Ops/sec
Ternary clamp inlined 3624690.8 Ops/sec
Ternary min inlined 6142225.0 Ops/sec
Ternary max inlined 6156567.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