Skip to content

Commit e66cbd5

Browse files
Add note on potential go benchmark optimisations (#781)
* Fix style of note on benchmarks running in sequence Note was italicized and didn't have a colon. This didn't match the other case of a note in the itegers chaper which was. * Add a note on go optimizing benchmarks Added a note on go optimizing benchmarks and a link to Dave Cheney's blog post on how to write benchmarks for how to make sure it doesn't. This optimization seems rare from reading issues online but does happen so warning would be good to let people know. * Fix wording to give a better sense of what go can do to optimize * Fix missing period
1 parent b6fe573 commit e66cbd5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

iteration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ PASS
123123

124124
What `136 ns/op` means is our function takes on average 136 nanoseconds to run \(on my computer\). Which is pretty ok! To test this it ran it 10000000 times.
125125

126-
_NOTE_ by default Benchmarks are run sequentially.
126+
**Note:** By default benchmarks are run sequentially.
127+
128+
**Note:** Sometimes, Go can optimize your benchmarks in a way that makes them inaccurate, such as eliminating the function being benchmarked. Check your benchmarks to see if the values make sense. If they seem overly optimized, you can follow the strategies in this **[blog post](https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go)**.
127129

128130
## Practice exercises
129131

0 commit comments

Comments
 (0)