Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
foo_trololololo
(version: 0)
Comparing performance of:
sdsdsdasdasfdasfafas vs asdasdasfsafsaf
Created:
6 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const treedboxToJson = async (data) => { let splited = data.split("\n"); let reduce = splited.reduce( (acc, curr) => { let arr = curr.split(" "); let position = arr.length; let data = arr[arr.length - 1].split(" "); let key = data[0]; let value = data[1] ? data[1] : ""; let id = Date.now() + Math.random() + Math.random(); let parent = acc._last && acc._last.position < position ? acc._last.id : ""; let siblings = acc._last && acc._last[position] ? acc._last[position] : ""; let obj = { [id]: { key, value, parent, siblings } }; return { ...acc, ...obj, _last: { ...acc._last, id, position, [position]: id } }; }, { _last: 0 } ); delete reduce._last; return JSON.stringify(reduce); }; const data = `pages default title nav pages main footer home main articles about main article 5 single article 2`; treedboxToJson(data);
Tests:
sdsdsdasdasfdasfafas
const treedboxToJson = async (data) => { const splited = data.split("\n"); const reduce = splited.reduce( (acc, curr) => { const arr = curr.split(" "); const position = arr.length; const data = arr[arr.length - 1].split(" "); const key = data[0]; const value = data[1] ? data[1] : ""; const id = Date.now() + Math.random() + Math.random(); const parent = acc._last && acc._last.position < position ? acc._last.id : ""; const siblings = acc._last && acc._last[position] ? acc._last[position] : ""; const obj = { [id]: { key, value, parent, siblings } }; return { ...acc, ...obj, _last: { ...acc._last, id, position, [position]: id } }; }, { _last: 0 } ); delete reduce._last; return JSON.stringify(reduce); }; const data = `pages default title nav pages main footer home main articles about main article 5 single article 2`; treedboxToJson(data);
asdasdasfsafsaf
const treedboxToJson = async (data) => { let splited = data.split("\n"); let reduce = splited.reduce( (acc, curr) => { let arr = curr.split(" "); let position = arr.length; let data = arr[arr.length - 1].split(" "); let key = data[0]; let value = data[1] ? data[1] : ""; let id = Date.now() + Math.random() + Math.random(); let parent = acc._last && acc._last.position < position ? acc._last.id : ""; let siblings = acc._last && acc._last[position] ? acc._last[position] : ""; let obj = { [id]: { key, value, parent, siblings } }; return { ...acc, ...obj, _last: { ...acc._last, id, position, [position]: id } }; }, { _last: 0 } ); delete reduce._last; return JSON.stringify(reduce); }; const data = `pages default title nav pages main footer home main articles about main article 5 single article 2`; treedboxToJson(data);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
sdsdsdasdasfdasfafas
asdasdasfsafsaf
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!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Don't worry, I'm here to help! **Benchmark Overview** The benchmark is designed to measure the performance of JavaScript code that processes a string representation of an object hierarchy. The input data is in JSON-like format, where each line represents a node in the hierarchy. **Options being compared** There are two options being compared: 1. **`treedboxToJson` function with `split` and `reduce`**: This implementation uses the `split` method to split the input string into an array of nodes, and then uses the `reduce` method to process each node and create a hierarchical object. 2. **`treedboxToJson` function without `split`**: This implementation does not use the `split` method and instead processes the input string directly. **Pros and Cons** **Option 1: `treedboxToJson` function with `split` and `reduce`** Pros: * More efficient, as it leverages built-in array methods * Easier to understand and maintain Cons: * May be slower due to the overhead of creating an array and executing the `reduce` method * Requires more memory allocation and garbage collection **Option 2: `treedboxToJson` function without `split`** Pros: * Potential for better performance, as it avoids the overhead of creating an array * Less memory allocation and garbage collection required Cons: * More complex implementation, making it harder to understand and maintain * May be slower due to the complexity of processing the input string directly **Latest Benchmark Result** The latest benchmark results show that the `treedboxToJson` function with `split` and `reduce` performs slightly better than the version without `split`. However, both implementations are very close in terms of performance. **Device and Browser Variations** It's worth noting that the device and browser variations can affect the performance results. The benchmark results show that Chrome 80 on Linux desktops performed best, with an average execution rate of approximately 6070 executions per second for each test name.
Related benchmarks:
[Object.entries after] Reduce vs Looping vs Ifs vs Destructuring
[Object.entries after fixed] Reduce vs Looping vs Ifs vs Destructuring
[Object.entries after fixed] Reduce vs Looping vs Ifs vs Destructuring vs Object.entries
test spreadpush on2
reduce vs plain cycle
Comments
Confirm delete:
Do you really want to delete benchmark?