]> Cypherpunks repositories - gostls13.git/commit
testing: only call ReadMemStats if necessary when benchmarking
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 10 Feb 2017 19:44:19 +0000 (11:44 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sat, 11 Feb 2017 02:35:59 +0000 (02:35 +0000)
commit948b21a3d7419ba42c574bde89c199b522221dc6
tree68db66abfab41776f0d613910542f15a1616c271
parent5157039fbd55e2fb7dfac6c461ca743ddced44bd
testing: only call ReadMemStats if necessary when benchmarking

When running benchmarks with -cpuprofile,
the entire process gets profiled,
and ReadMemStats is surprisingly expensive.
Running the sort benchmarks right now with
-cpuprofile shows almost half of all execution
time in ReadMemStats.

Since ReadMemStats is not required if the benchmark
does not need allocation stats, simply skip it.
This will make cpu profiles nicer to read
and significantly speed up the process of running benchmarks.
It might also make sense to toggle cpu profiling
on/off as we begin/end individual benchmarks,
but that wouldn't get us the time savings of
skipping ReadMemStats, so this CL is useful in itself.

Change-Id: I425197b1ee11be4bc91d22b929e2caf648ebd7c5
Reviewed-on: https://go-review.googlesource.com/36791
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/testing/benchmark.go
src/testing/sub_test.go