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

Question regarding tests #38

Closed
cristaloleg opened this issue Sep 13, 2016 · 1 comment
Closed

Question regarding tests #38

cristaloleg opened this issue Sep 13, 2016 · 1 comment
Labels

Comments

@cristaloleg
Copy link

cristaloleg commented Sep 13, 2016

Hi. I've a few questions about tests in binaryheap_test.go by example.

  1. Why you disable timer at the beginning of the test and then enable it at the end?
  2. You're pushing 100 elements, but then popping 100 * b.N, so pop function returns nothing. Am I missing something or this is a bug?

Thank you.

@emirpasic
Copy link
Owner

Perhaps, which is most likely, is that I did not understand the question. So excuse me if my answer misses the point.

That is a benchmark for popping, so the initialization step of populating (pushing) the heap should not be part of the benchmark, hence the stopping of the timer.

The pop function removes the element from the heap, which bubbles down the root elements, thus changing the internal storage. The function does return a value, that is not captured in the test as you said, but that shouldn't make much difference to the benchmark, right?

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

No branches or pull requests

2 participants