Question regarding tests #38

Closed
opened 2016-09-13 16:16:27 +00:00 by cristaloleg · 1 comment
cristaloleg commented 2016-09-13 16:16:27 +00:00 (Migrated from github.com)

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.

Hi. I've a few questions about tests in [binaryheap_test.go](https://github.com/emirpasic/gods/blob/master/trees/binaryheap/binaryheap_test.go#L278) 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 commented 2016-09-14 20:13:14 +00:00 (Migrated from github.com)

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?

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 in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
golibs/gms-gods#38
No description provided.