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. apidiff/
  2. cmd/
  3. ebnf/
  4. ebnflint/
  5. errors/
  6. event/
  7. fsnotify/
  8. inotify/
  9. io/
  10. mmap/
  11. rand/
  12. shiny/
  13. shootout/
  14. sumdb/
  15. utf8string/
  16. winfsnotify/
  17. .gitattributes
  18. .gitignore
  19. AUTHORS
  20. codereview.cfg
  21. CONTRIBUTING.md
  22. CONTRIBUTORS
  23. go.mod
  24. go.sum
  25. LICENSE
  26. PATENTS
  27. README.md
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.