Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Performance Test: substring vs substr vs slice (remove last char)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
slice
20.9M/s
substring
11.4M/s
substr
11.3M/s
View exact numbers
Test name
Executions per second
✓
slice
20,907,486 Ops/sec
substring
11,354,052 Ops/sec
substr
11,306,389 Ops/sec
Script Preparation code:
var string = "I am the god of hellfire, and I bring you..."
Tests:
slice
var substring = string.slice(0, -1);
substring
var substring = string.substring(0, string.length - 1);
substr
var substring = string.substr(0, string.length - 1);