event: add benchmarks for context lookups

See how much it costs to look up the exporter in the context.

The results (see below) show that with a context chain of length 10,
doing a context lookup is about 20% slower than not.

go test -v -run XXX -bench BuildContext
goos: linux
goarch: amd64
pkg: golang.org/x/exp/event
cpu: Intel(R) Xeon(R) CPU @ 2.30GHz
BenchmarkBuildContext
BenchmarkBuildContext/depth_1
BenchmarkBuildContext/depth_1/with
BenchmarkBuildContext/depth_1/with-8             6222020               192.8 ns/op
BenchmarkBuildContext/depth_1/without
BenchmarkBuildContext/depth_1/without-8          5743065               182.9 ns/op
BenchmarkBuildContext/depth_5
BenchmarkBuildContext/depth_5/with
BenchmarkBuildContext/depth_5/with-8             6233917               184.8 ns/op
BenchmarkBuildContext/depth_5/without
BenchmarkBuildContext/depth_5/without-8          7289814               165.8 ns/op
BenchmarkBuildContext/depth_7
BenchmarkBuildContext/depth_7/with
BenchmarkBuildContext/depth_7/with-8             5941093               193.5 ns/op
BenchmarkBuildContext/depth_7/without
BenchmarkBuildContext/depth_7/without-8          7317411               167.6 ns/op
BenchmarkBuildContext/depth_10
BenchmarkBuildContext/depth_10/with
BenchmarkBuildContext/depth_10/with-8            5709080               207.0 ns/op
BenchmarkBuildContext/depth_10/without
BenchmarkBuildContext/depth_10/without-8                 7281186               168.9 ns/op

Change-Id: If38409916240dd15d4924505aa80f98c107830e4
Reviewed-on: https://go-review.googlesource.com/c/exp/+/325489
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
1 file changed
tree: a8da160bef8013dc018847a15181315910862d3e
  1. .gitattributes
  2. .gitignore
  3. AUTHORS
  4. CONTRIBUTING.md
  5. CONTRIBUTORS
  6. LICENSE
  7. PATENTS
  8. README.md
  9. apidiff/
  10. cmd/
  11. codereview.cfg
  12. ebnf/
  13. ebnflint/
  14. errors/
  15. event/
  16. fsnotify/
  17. go.mod
  18. go.sum
  19. inotify/
  20. io/
  21. mmap/
  22. rand/
  23. shiny/
  24. shootout/
  25. sumdb/
  26. utf8string/
  27. winfsnotify/
README.md

exp

PkgGoDev

This subrepository holds experimental and deprecated (in the old directory) packages.

The idea for this subrepository originated as the pkg/exp directory of the main repository, but its presence there made it unavailable to users of the binary downloads of the Go installation. The subrepository has therefore been created to make it possible to go get these packages.

Warning: Packages here are experimental and unreliable. Some may one day be promoted to the main repository or other subrepository, or they may be modified arbitrarily or even disappear altogether.

In short, code in this subrepository is not subject to the Go 1 compatibility promise. (No subrepo is, but the promise is even more likely to be violated by go.exp than the others.)

Caveat emptor.