Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
딥카피테스트
(version: 0)
test
Comparing performance of:
재귀 vs 네이티브
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
재귀
const testArray = [ { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { myName: 'test name', myNumber: 123245, }, ], }, { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { myName: 'test name', myNumber: 123245, }, ], }, { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { myName: 'test name', myNumber: 123245, }, ], }, ], }, ], }, { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, testArray: [ { myName: 'test name', myNumber: 123245, }, ], }, ]; var copyObjectDeep = function (target) { var result = {}; // null의 type도 object이기 때문에 target !== null 조건 추가 if (typeof target === 'object' && target !== null) { for (var prop in target) { result[prop] = copyObjectDeep(target[prop]); } } else { result = target; } return result; } var testCopy = null; testCopy = copyObjectDeep(testArray);
네이티브
const testArray = [ { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { myName: 'test name', myNumber: 123245, }, ], }, { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { myName: 'test name', myNumber: 123245, }, ], }, { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, arr: [ { myName: 'test name', myNumber: 123245, }, ], }, ], }, ], }, { description: 'Random description.', testNumber: 123456789, testBoolean: true, testObject: { testString: 'test string', testNumber: 12345, }, testArray: [ { myName: 'test name', myNumber: 123245, }, ], }, ]; var testCopy = null; testCopy = structuredClone(testArray);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
재귀
네이티브
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):
I'll break down the provided benchmark and explain what's being tested, compared, and other considerations. **Benchmark Overview** The benchmark consists of two test cases: "재귀" (Recursive) and "네이티브" (Native). The tests measure the performance of deep object copying using two different approaches: a custom recursive function (`copyObjectDeep`) and a built-in `structuredClone` method. **Test Case 1: "재귀" (Recursive)** In this test case, the benchmark measures the execution time of a custom recursive function that copies an array of objects. The function is defined as follows: ```javascript var copyObjectDeep = function (target) { var result = {}; // null의 type도 object이기 때문에 null을 target에 include하고 있다. if (typeof target === 'object' && target !== null) { for (var key in target) { if (Object.prototype.hasOwnProperty.call(target, key)) { result[key] = copyObjectDeep(target[key]); } } } else { result = target; } return result; }; ``` The benchmark creates a large array of objects and measures the time it takes to execute the `copyObjectDeep` function on that array. **Test Case 2: "네이티브" (Native)** In this test case, the benchmark measures the execution time of the built-in `structuredClone` method, which is used to create a shallow copy of an object. The benchmark creates a large array of objects and measures the time it takes to execute the `structuredClone` function on that array. **Comparison** The two test cases are compared based on their execution times. The results show that: * "네이티브" (Native) is significantly faster than "재귀" (Recursive). * The native implementation has an average execution time of 385,839 executions per second. * The recursive implementation has an average execution time of 132,408 executions per second. **Considerations** The main differences between the two implementations are: * **Complexity**: The recursive implementation is more complex and has a higher overhead due to the repeated function calls. * **Memory allocation**: The native implementation allocates memory only once for the cloned object, while the recursive implementation allocates memory repeatedly for each nested object. * **Cache efficiency**: The native implementation is likely to be more cache-efficient since it doesn't require multiple function calls and can reuse existing memory allocations. Overall, the benchmark results suggest that the native `structuredClone` method is a more efficient way to copy large objects in JavaScript.
Related benchmarks:
getComputedTextLength vs Canvas.2D.measureText
Window Perf
Measure Text Methods fairer
document.documentElement.clientWidth/Height vs window.innerWidth/Height
getComputedStyle vs clientWidth
Comments
Confirm delete:
Do you really want to delete benchmark?