Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
endsWith vs at vs trimEnd 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/136.0.0.0 Safari/537.36
Browser:
Chrome 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
11 months ago
Test name
Executions per second
endsWith
623825.1 Ops/sec
at
640825.4 Ops/sec
regex
613819.4 Ops/sec
trimEnd
608296.2 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function generateRandomText(length) { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 '; let result = ''; for (let i = 0; i < length; i++) { const randomIndex = Math.floor(Math.random() * chars.length); result += chars[randomIndex]; } return result; } const test = new Array(1000).map(e => generateRandomText(100))
Tests:
endsWith
test.filter(t => t.endsWith(" ") || t.endsWith("\n") || t.endsWith("\t") || t.endsWith("\r") || t.endsWith("\f") || t.endsWith("\v"))
at
test.filter(t =>{const l = t.at(t.length - 1); return l === " " || l === "\n" || l === "\t"|| l === "\r" || l === "\f" || l === "\v" })
regex
test.filter(t => /\s$/.test(t))
trimEnd
test.filter(t => (t.trimEnd().length !== t.length))