[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread Egon
Sorry for creating confusion, my reading mistake. I read the inner-loop as: if err := bdb.Get(key, ); err == nil && val.Value() != nil { totalFound++ } else if err != nil { totalErrored++ } else { totalNotFound++ } Which it obviously is not... :/ This day doesn't seem promising after this

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread peterGo
Egon, Obviously I ran the race detector. No races were detected. Therefore, since it wasn't germane, I omitted it from the posted results. Here's my results. $ go test -run=! -bench=. -v -cpu=4 -race total_test.go goos: linux goarch: amd64 BenchmarkTotal/Count-4 5000

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread Egon
Note, you also have a race in your code. Use `-race` to detect. + Egon On Thursday, 10 August 2017 06:43:34 UTC+3, d...@dgraph.io wrote: > > Hi > > I am trying to benchmark a key-value store written in Go. I have the code > as shown below. There are a few lines that are specific to the store

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread peterGo
Package testing https://golang.org/pkg/testing/ Benchmarks The benchmark function must run the target code b.N times. During benchmark execution, b.N is adjusted until the benchmark function lasts long enough to be timed reliably. The first thing to do is to reduce the program to the simplest