Run details:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36
Chrome 91
Windows 7
Desktop
3 years ago
Test name Executions per second
Math.min/max 823467.1 Ops/sec
Math.min 1414619.0 Ops/sec
Math.max 1453814.0 Ops/sec
Ternary clamp 1283851.0 Ops/sec
Ternary min 1800640.0 Ops/sec
Ternary max 1803567.0 Ops/sec
Ternary clamp inlined 989643.1 Ops/sec
Ternary min inlined 1785203.0 Ops/sec
Ternary max inlined 1808077.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