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 (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
slice
33.4M/s
substr
17.8M/s
substring
17.6M/s
View exact numbers
Test name
Executions per second
✓
slice
33,423,596 Ops/sec
substr
17,777,142 Ops/sec
substring
17,608,940 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);