chore: add benchmark case for horizontal coedges #521
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Angus,
Hope it's been going well for you lately.
![input_coedge_2023-05-09_18-35-38](https://private-user-images.githubusercontent.com/21260868/237073126-3f132473-0f91-43a0-91ed-99f632bd5385.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0MzEwMzIsIm5iZiI6MTcyMDQzMDczMiwicGF0aCI6Ii8yMTI2MDg2OC8yMzcwNzMxMjYtM2YxMzI0NzMtMGY5MS00M2EwLTkxZWQtOTlmNjMyYmQ1Mzg1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDA5MjUzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlhODU0YTk2ZWJkYmE3ZDBmMzJhNTlmZDQ1MjAwZGY2ZDEyNDdlZDY3MDUwMGE5MWJkN2U0Mzk1YjQ4OTZmOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.wxqJoy8kTsSAqsHgsm1_wS8-IATwH6SSl0P6CAXm4_Y)
Recently in my use case, i found one specific case that is very time consuming, it has many horizontal coedges and looks like the following image:
I have extended the coedge numbers and wrote a simple benchmark file in the pull request. The runtime is approximately to be O(N^2) as I increase the horizontal coedge numbers.
![benchmark_result_2023-05-09_18-29-35](https://private-user-images.githubusercontent.com/21260868/237073841-89ddd3c2-d09f-4c07-9507-a869103ecb7d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0MzEwMzIsIm5iZiI6MTcyMDQzMDczMiwicGF0aCI6Ii8yMTI2MDg2OC8yMzcwNzM4NDEtODlkZGQzYzItZDA5Zi00YzA3LTk1MDctYTg2OTEwM2VjYjdkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA4VDA5MjUzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFiNjZkMmQ5YTA0NGExOGVhNWNhNjEwNTFkNDdjZTkzMGZkNzdmODI0MTE0MDQ3OGVhZjAxZDYyMjBkY2E4NWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.JL3sqnJnQ0pAgUJ5IkwRZ4jdz0ZyzTDsldSTSr8fdmU)
Through profiling, i found most time is spent on the following two functions:
Clipper2Lib::GetMaximaPair
Clipper2Lib::IsValidAelOrder
It seems that this is related to the internal data structure linked list and the search time is O(N). Do you have any suggestions on how to improve this runtime?