Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Reverse and find vs rediceRight vs find index vs find last
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0
Browser:
Firefox 123
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Reverse and find
2865036.8 Ops/sec
rediceRight
619960.5 Ops/sec
findLastIndex
22126136.0 Ops/sec
findLast
22189688.0 Ops/sec
ReduceRight and slice
647196.1 Ops/sec
Script Preparation code:
test = 'Low-life writer and unrepentant alcoholic Henry Chinaski was born to survive. After decades of slacking off at low-paying dead-end jobs, blowing his cash on booze and Women, and scrimping by in flea-bitten apartments, Chinaski sees his poetic star rising at last. Now, at fifty, he is reveling in his sudden rock-star life, running three hundred hangovers a year, and maintaining a sex life that would cripple Casanova'.split('');
Tests:
Reverse and find
test.reverse().find(s => s === 'f')
rediceRight
test.reduceRight((r, s) => (r || (s === 'f' ? s : r)), undefined)
findLastIndex
test[test.findLastIndex(s => s === 'f')]
findLast
test.findLast(s => s === 'f')
ReduceRight and slice
test.slice(0).reduceRight((r, s, i, arr) => (r || (s === 'f' ? (arr.length = 0, s) : r)), undefined)