FAQ
Looks good. Some suggestions below.


https://codereview.appspot.com/6613064/diff/3001/src/pkg/container/heap/heap_test.go
File src/pkg/container/heap/heap_test.go (right):

https://codereview.appspot.com/6613064/diff/3001/src/pkg/container/heap/heap_test.go#newcode176
src/pkg/container/heap/heap_test.go:176: h := new(myHeap)
You can move this outside the loop - no need to measure creation as
well. After each iteration, the heap is empty again.

You could even pre-allocate it, so that the append doesn't have to grow
the heap:

const n = 10000
h := make(myHeap, n)

as in:

const n = 10000
h := make(myHeap, n)
for i := 0; i < b.N; i++ {
for j := 0; j < n; j++ {
Push(&h, 0) // all elements are the same
}
for h.Len() > 0 {
Pop(&h)
}
}

This way, we really just measure the cost of a pure Push and Pop.

https://codereview.appspot.com/6613064/

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 10, '12 at 1:29a
activeOct 10, '12 at 7:33p
posts5
users2
websitegolang.org

2 users in discussion

Gri: 3 posts Taj Khattra: 2 posts

People

Translate

site design / logo © 2022 Grokbase