Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Test To fixed vs regex
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36
Browser:
Chrome 99
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Regex
13.4M/s
toFixed
5.5M/s
View exact numbers
Test name
Executions per second
✓
Regex
13,440,631 Ops/sec
toFixed
5,468,258 Ops/sec
Tests:
Regex
var x = 12.030303; x.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0];
toFixed
var x = 12.030303; x.toFixed(2);