Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
reduce performance
(version: 1)
reduce slice performance
Comparing performance of:
slice-1 vs slice-2
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
function randomString(e) { e = e || 32; var t = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678", a = t.length, n = ""; for (i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a)); return n } var str1 = randomString(100) var str2 = randomString(100000)
Tests:
slice-1
var result1 = Array.from(str1.slice(1, 3)).reduce(function (previousValue, currentValue, index, array) { return previousValue + currentValue; }) var result2 = Array.from(str1.slice(4, 6)).reduce(function (previousValue, currentValue, index, array) { return previousValue + currentValue; }) var result3 = Array.from(str1.slice(7, 10)).reduce(function (previousValue, currentValue, index, array) { return previousValue + currentValue; })
slice-2
var result1 = Array.from(str2.slice(1, 30000)).reduce(function (previousValue, currentValue, index, array) { return previousValue + currentValue; }) var result2 = Array.from(str2.slice(28999, 69999)).reduce(function (previousValue, currentValue, index, array) { return previousValue + currentValue; }) var result3 = Array.from(str2.slice(67000, 99999)).reduce(function (previousValue, currentValue, index, array) { return previousValue + currentValue; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
slice-1
slice-2
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Browser/OS:
Safari 17 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
slice-1
1402509.4 Ops/sec
slice-2
482.5 Ops/sec
Related benchmarks:
Text.data vs Text.nodeValue
Lodash _.some vs _.includes
create temp object vs Object.fromEntries
slice performance
js slice performance
js slice performance -2
js splice v toSpliced improved
lodash _.some vs Array.some
normalize / trim text
Comments
Confirm delete:
Do you really want to delete benchmark?