jjones-99 / cs4500-sp2020-a1-part2-jones-tam

Jackie Tam and Jared Jones' work for Assignment 1: Part 2 of Software Development in Spring 2020.
0 stars 2 forks source link

Testing Large Map #16

Closed grahamwren closed 4 years ago

grahamwren commented 4 years ago

No specific opinion one way or the other, but did you consider adding a test for a very large map to try to exercise the rehash behavior requested in the assignment?

The performance of the Map class should be tuned to avoid pathological cases by rehashing when the load gets too high.

grahamwren commented 4 years ago

We haven't come up with a way to externally validate that a rehash happened so haven't submitted a PR but wanted to know if you'd looked into it.

jjones-99 commented 4 years ago

We tested our rehashing behavior by adding enough elements that a rehash should happen (we temporarily printed a statement when our helper was called so we knew it triggered) and then confirmed that all of our functionality still worked, especially on elements added before the rehash happened. If the test focuses on the public face of the implementation, what matters is that the Map works the same before and after a rehash.

Because rehashing and the threshold is something of the implementation, it's difficult to make a test specifically to target rehashing. Still, it doesn't hurt to have a test with a large Map (I figure ~35 elements should trigger most rehashes?). I can bang one out real quick and push it. If people want to pull it and/or update their commit hashes in their Makefiles to match, it'll be there.

grahamwren commented 4 years ago

We default to 1024 buckets with a max bucket size of 3 so would need closer to 500-2000 inserts. I can open a PR for that if it seems like a worthwhile test to you.

jjones-99 commented 4 years ago

Oh wow, that's a big Map. I'm doing homework for some other classes at the moment, so if you know a good way to make a test like that, go right ahead. 👍 I don't want any of you to have rehashing bugs go unnoticed.

grahamwren commented 4 years ago

Glad we did this, found some bugs at the larger sizes ✌️PR incoming

jjones-99 commented 4 years ago

Awesome, glad they were caught!