Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
재귕ㄴㅁㄹㄴㅁㅇㄹㅁㄴㅇ
(version: 1)
Comparing performance of:
org vs mdf
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const createNestedOptions = (depth, breadth) => { if (depth === 0) { return { good_price: 10, good_qty: 1 }; } return { good_price: 10, good_qty: 1, option: Array(breadth) .fill(null) .map(() => createNestedOptions(depth - 1, breadth)), }; }; const sampleData = { good_price: 100, good_qty: 2, option: [ createNestedOptions(10, 3), // 깊이 10, 너비 3의 중첩된 옵션 createNestedOptions(10, 5), // 깊이 10, 너비 5의 중첩된 옵션 ], };
Tests:
org
const orderProductTotalPrice = (product) => { const optionTotalPrice = (option) => { const optionPrice = option ? option.good_price * option.good_qty : 0; const childOptionPrice = option.option?.reduce((acc, cur) => { return acc + optionTotalPrice(cur); }, 0) || 0; return optionPrice + childOptionPrice; }; const { good_price, good_qty, option = [] } = product; const productPrice = Number(good_price) * Number(good_qty); const optionPrice = option.reduce((acc, cur) => { return acc + optionTotalPrice(cur); }, 0); return productPrice + optionPrice; }; orderProductTotalPrice(sampleData)
mdf
const orderProductTotalPrice = (product) => { const optionTotalPrice = (options) => { const stack = [...options]; // 옵션을 스택으로 초기화 let totalPrice = 0; while (stack.length > 0) { const currentOption = stack.pop(); if (currentOption) { totalPrice += currentOption.good_price * currentOption.good_qty; // 자식 옵션이 있으면 스택에 추가 if (currentOption.option) { stack.push(...currentOption.option); } } } return totalPrice; }; const { good_price, good_qty, option = [] } = product; const productPrice = Number(good_price) * Number(good_qty); const optionPrice = optionTotalPrice(option); return productPrice + optionPrice; }; orderProductTotalPrice(sampleData)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
org
mdf
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!
Comments
Confirm delete:
Do you really want to delete benchmark?