Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
getRelevantPositions
(version: 0)
Comparing performance of:
Stara opcja vs Nowa opcja
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
Stara opcja
const IRRELEVANT_PARAGRAPHS = [ '401', '402', '404', '405', '406', '407', '408', '409', '410', '411', '412', '417', '418', '471', '474', '475', '478', '479', '480', '483', '484', '485', '801', '804', '806', '807', '808', '809', '810', '811', '812', '813', '814', '605', '606', '610', '613', '615', '617', '619', '620', '621', '622', '623', '625', '630', '637', '647', '648', '649', '656', '657', '658', '659', '661', '662', '663', '664', '665', '666', '669', '672', '680', ]; const IRRELEVANT_GROUPS = ['1400', '1810', '1600', '1601', '1602', '1610', '1611', '1612']; const positions = []; const classificationDetailLevels = ['paragraph', 'systemGroup', 'ordinanceGroup']; for (let i = 0; i < 1000; i++) { const randomIndex = Math.floor(Math.random() * classificationDetailLevels.length); positions.push({ paragraph: `Paragraph ${Math.floor(Math.random() * 10)}`, group: `Group ${Math.floor(Math.random() * 5)}`, }); } const getRelevantPositions = (outgoings, classificationDetailLevel) => outgoings.filter((position) => { switch (classificationDetailLevel) { case 'paragraph': return position.paragraph && !IRRELEVANT_PARAGRAPHS.includes(position.paragraph); case 'systemGroup': case 'ordinanceGroup': return position.group && !IRRELEVANT_GROUPS.includes(position.group); default: return false; } }); classificationDetailLevels.forEach((classificationDetailLevel) => getRelevantPositions(positions, classificationDetailLevel))
Nowa opcja
const IRRELEVANT_PARAGRAPHS = [ '401', '402', '404', '405', '406', '407', '408', '409', '410', '411', '412', '417', '418', '471', '474', '475', '478', '479', '480', '483', '484', '485', '801', '804', '806', '807', '808', '809', '810', '811', '812', '813', '814', '605', '606', '610', '613', '615', '617', '619', '620', '621', '622', '623', '625', '630', '637', '647', '648', '649', '656', '657', '658', '659', '661', '662', '663', '664', '665', '666', '669', '672', '680', ]; const IRRELEVANT_GROUPS = ['1400', '1810', '1600', '1601', '1602', '1610', '1611', '1612']; const positions = []; const classificationDetailLevels = ['paragraph', 'systemGroup', 'ordinanceGroup']; for (let i = 0; i < 1000; i++) { const randomIndex = Math.floor(Math.random() * classificationDetailLevels.length); positions.push({ paragraph: `Paragraph ${Math.floor(Math.random() * 10)}`, group: `Group ${Math.floor(Math.random() * 5)}`, }); } const getRelevantPositions = ({ outgoings, classificationDetailLevel }) => { let condition; switch (classificationDetailLevel) { case 'paragraph': condition = (position) => position.paragraph && !IRRELEVANT_PARAGRAPHS.includes(position.paragraph); break; case 'systemGroup': case 'ordinanceGroup': condition = (position) => position.group && !IRRELEVANT_GROUPS.includes(position.group); break; return outgoings.filter(contidion) } } classificationDetailLevels.forEach((classificationDetailLevel) => getRelevantPositions(positions, classificationDetailLevel))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Stara opcja
Nowa opcja
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser/OS:
Chrome 123 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Stara opcja
1626.7 Ops/sec
Nowa opcja
1976.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the benchmark definition and test cases to explain what's being tested, compared, and their pros and cons. **Benchmark Definition** The benchmark definition is empty, which means that MeasureThat.net will use its own default configuration for the benchmark. **Individual Test Cases** There are two test cases: 1. **Stara opcja (Old Option)** This test case uses a traditional switch statement to filter out irrelevant positions: ```javascript const getRelevantPositions = (outgoings, classificationDetailLevel) => { let condition; switch (classificationDetailLevel) { case 'paragraph': condition = (position) => position.paragraph && !IRRELEVANT_PARAGRAPHS.includes(position.paragraph); break; case 'systemGroup': case 'ordinanceGroup': condition = (position) => position.group && !IRRELEVANT_GROUPS.includes(position.group); break; } return outgoings.filter(condition) } ``` 2. **Nowa opcja (New Option)** This test case uses a more concise syntax with an arrow function to define the filter condition: ```javascript const getRelevantPositions = ({ outgoings, classificationDetailLevel }) => { let condition; switch (classificationDetailLevel) { case 'paragraph': condition = (position) => position.paragraph && !IRRELEVANT_PARAGRAPHS.includes(position.paragraph); break; case 'systemGroup': case 'ordinanceGroup': condition = (position) => position.group && !IRRELEVANT_GROUPS.includes(position.group); break; } return outgoings.filter(condition) } ``` **What's being tested?** Both test cases are testing the performance of the `getRelevantPositions` function, which filters out irrelevant positions based on a given classification detail level. The main difference between the two is the syntax used to define the filter condition. **Comparison** MeasureThat.net will compare the execution times of both test cases using the same input data. This allows users to see how the performance of the `getRelevantPositions` function varies depending on the chosen syntax. **Pros and Cons** The traditional switch statement (Stara opcja) has some pros: * Easy to understand for developers familiar with traditional switch statements. * May be more readable for those who prefer a explicit, step-by-step approach. However, it also has some cons: * Can be less concise and more verbose than the new syntax. * May not be as performant due to the overhead of explicit type checking and function definitions. The new syntax (Nowa opcja) has some pros: * More concise and readable for developers familiar with modern JavaScript features. * May be faster due to reduced overhead from explicit type checking and function definitions. However, it also has some cons: * Can be less intuitive for developers unfamiliar with arrow functions and concise syntax. * May not be as widely supported across different browsers and environments. Overall, MeasureThat.net will provide users with a clear comparison of the performance differences between these two syntax options.
Related benchmarks:
Lodash isEqual test - events object
Lodash isEqual test vs strict equality check
Equality test
Lodash isEqual test vs Custom Recursive Function
Lodash isEqual compare with custom deepEqual in compare objects 1
Comments
Confirm delete:
Do you really want to delete benchmark?