Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
parse list of bytes
(version: 0)
Comparing performance of:
split vs split no init size vs byte array vs json nonsense
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function makeString() { return Array.from(Array(1000)) .map(() => (Math.random() * 256) | 0) .join(","); } var str = makeString(); window.output=null;
Tests:
split
const uintStrings = str.split(","); const len = uintStrings.length; const uintArray = new Array(len); for (let i = 0; i < len; ++i) { uintArray[i] = parseInt(uintStrings[i]); } window.output= uintArray;
split no init size
const uintStrings = str.split(","); const len = uintStrings.length; const uintArray = new Array(); for (let i = 0; i < len; ++i) { uintArray[i] = parseInt(uintStrings[i]); } window.output=uintArray;
byte array
const uintStrings = str.split(","); const len = uintStrings.length; const uintArray = new Uint8Array(len); for (let i = 0; i < len; ++i) { uintArray[i] = parseInt(uintStrings[i]); } window.output=uintArray;
json nonsense
window.output=JSON.parse(`[${str}]`);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
split
split no init size
byte array
json nonsense
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser/OS:
Firefox 132 on Ubuntu
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
split
50670.1 Ops/sec
split no init size
47512.2 Ops/sec
byte array
67909.8 Ops/sec
json nonsense
48067.9 Ops/sec
Related benchmarks:
Lodash vs vanila 2
.startsWith vs .charAt vs str[0] for single character
Random hex string generation benchmark
Split vs Spread (randomized)
Comments
Confirm delete:
Do you really want to delete benchmark?