Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark for Contains #10

Closed
miroslavp opened this issue Feb 23, 2023 · 4 comments
Closed

Benchmark for Contains #10

miroslavp opened this issue Feb 23, 2023 · 4 comments

Comments

@miroslavp
Copy link
Contributor

Hi,
Do you have any rough idea how the Contains method of these collections compares to those in Dictionary and SlimDictionary in terms of performance? Can you add benchmarks when you get free time for cases when the key is present and not present in the collection?

Thank you for the great work!

@Wsm2110
Copy link
Owner

Wsm2110 commented Feb 23, 2023

Well the thing is, contains isn't really needed. Get() will always return false if the key isn't present. Nonetheless contains() pretty much uses the same code as Get().

Not sure if a contains() benchmark will differ alot from the Get benchmark

@miroslavp
Copy link
Contributor Author

Right, I just noticed that the implementation of Dictionary.TryGetValue and Dictionary.ContainsKey is also pretty much the same. So you are correct that performance-wise Get and Contains are equivalent for all the collections. Do you think though that it would be interesting to have a benchmark where let's say half of the keys passed to Get() are not present in the map. I wonder if the results would be much different when searching for non-existent keys.
Thank you for your time!

@Wsm2110
Copy link
Owner

Wsm2110 commented Feb 23, 2023 via email

@Wsm2110
Copy link
Owner

Wsm2110 commented Feb 23, 2023

fixed, adding a benchmark later on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants