Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Getting last part of path pre init regex
(version: 0)
Comparing performance of:
regex vs pop vs slice
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var list = []; for (var i = 0; i < 1000; i++) { list.push("/foofoo/barbar/asdasdasdasd/foofoobarbar"); } var regex = /\/([^\/]+)$/;
Tests:
regex
list.forEach(item => { var parts = regex.exec(item); })
pop
list.forEach(item => { item.split("/").pop() })
slice
list.forEach(item => { item.slice(item.lastIndexOf("/") + 1); })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
regex
pop
slice
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Take last part from URL (Regex vs split)
get last element of path: split vs regex
Getting last part of path
Get last path part - Regex vs split
Comments
Confirm delete:
Do you really want to delete benchmark?