Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
leftPad vs nativeLeftPad
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
nativeLeftPad
10.8M/s
leftPad
8.9M/s
View exact numbers
Test name
Executions per second
✓
nativeLeftPad
10,811,108 Ops/sec
leftPad
8,941,133 Ops/sec
Tests:
nativeLeftPad
function nativeLeftPad(string, len, ch) { return string.padStart(len, ch); } nativeLeftPad('abcdefg', 10, '0')
leftPad
function leftPad(str, len, ch) { let new_str = `${ch.repeat(len)}${str}`; return new_str.slice(-len); } leftPad('abcdefg', 10, '0')