go/src/testing
Bryan Boreham 4c174a7ba6 testing: reduce memory allocation in Helper
Store the PC instead of the string name of the function, and defer
that conversion until we need it.

Helper is still relatively expensive in CPU time (few hundred ns),
but memory allocation is now constant for a test rather than linear in
the number of times Helper is called.

benchstat:
name        old time/op    new time/op    delta
TBHelper-4    1.30µs ±27%    0.53µs ± 1%   -59.03%  (p=0.008 n=5+5)

name        old alloc/op   new alloc/op   delta
TBHelper-4      216B ± 0%        0B       -100.00%  (p=0.008 n=5+5)

name        old allocs/op  new allocs/op  delta
TBHelper-4      2.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)

Change-Id: I6565feb491513815e1058637d086b0374fa94e19
GitHub-Last-Rev: c2329cf225
GitHub-Pull-Request: golang/go#38834
Reviewed-on: https://go-review.googlesource.com/c/go/+/231717
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-11-11 20:48:31 +00:00
..
fstest io/fs, path, path/filepath, testing/fstest: validate patterns in Match, Glob 2020-10-23 14:59:03 +00:00
internal/testdeps cmd/go, testing, os: fail test that calls os.Exit(0) 2020-08-27 23:19:15 +00:00
iotest all: update references to symbols moved from io/ioutil to io 2020-10-20 18:41:18 +00:00
quick all: shorten some tests 2019-05-22 12:54:00 +00:00
allocs.go
allocs_test.go
benchmark.go testing: increase benchmark output to four significant figures 2020-11-07 22:38:01 +00:00
benchmark_test.go testing: increase benchmark output to four significant figures 2020-11-07 22:38:01 +00:00
cover.go testing/cover: improve message when a package has no statements 2019-03-13 04:11:58 +00:00
example.go testing: fail Example tests that invoke runtime.Goexit 2020-09-01 20:13:34 +00:00
export_test.go testing: stop rounding b.N 2019-03-20 21:19:16 +00:00
helper_test.go testing: add benchmark for TB.Helper 2020-09-28 20:51:39 +00:00
helperfuncs_test.go testing: fix reported caller name for funcs passed to Cleanup 2020-05-05 22:44:36 +00:00
match.go testing: fix typo mistake 2018-04-27 13:29:12 +00:00
match_test.go
panic_test.go testing: don't run Cleanup functions until parallel subtests complete 2020-01-16 21:32:12 +00:00
run_example.go testing: fail Example tests that invoke runtime.Goexit 2020-09-01 20:13:34 +00:00
run_example_js.go testing: fail Example tests that invoke runtime.Goexit 2020-09-01 20:13:34 +00:00
sub_test.go testing: flush test summaries to stdout atomically when streaming output 2020-09-02 14:22:42 +00:00
testing.go testing: reduce memory allocation in Helper 2020-11-11 20:48:31 +00:00
testing_test.go testing: make TempDir idempotent for both Cleanup and Benchmark 2020-09-05 04:21:49 +00:00