event: detect failure to clone

If the user of a Builder forgets to call Clone and delivers a second
event, panic with a helpful message.

This does seem to slow down the no-op case:

> benchstat2 -C . bench.log
name                  old time/op  new time/op  delta
LogEventNoExporter-8   621ns ± 3%   613ns ± 1%   -1.22%  (p=0.000 n=19+18)
LogEventNoop-8        1.84µs ± 1%  2.04µs ± 2%  +10.83%  (p=0.000 n=17+19)
LogEventDiscard-8     10.7µs ± 3%  10.6µs ± 1%   -0.86%  (p=0.017 n=19+19)
LogEventfDiscard-8    16.4µs ± 3%  16.6µs ± 3%   +1.12%  (p=0.001 n=18+19)
TraceEventNoop-8      40.7µs ± 2%  41.0µs ± 3%     ~     (p=0.119 n=18+20)
MetricEventNoop-8     18.2µs ± 2%  18.3µs ± 3%     ~     (p=0.703 n=20+20)
Logrus-8              53.7µs ± 5%  53.8µs ± 3%     ~     (p=0.779 n=20+20)
Logrusf-8             44.6µs ± 3%  45.2µs ± 5%   +1.20%  (p=0.046 n=19+20)
Baseline-8             278ns ± 2%   278ns ± 1%     ~     (p=0.642 n=18+17)
LogStdlib-8           8.41µs ± 4%  8.39µs ± 2%     ~     (p=0.767 n=19+19)
LogPrintf-8           13.0µs ± 2%  13.0µs ± 2%     ~     (p=0.075 n=19+20)
LogZap-8              19.6µs ± 3%  19.6µs ± 3%     ~     (p=0.390 n=19+19)
LogZapf-8             21.4µs ± 2%  21.5µs ± 2%     ~     (p=0.208 n=19+17)
LogZerolog-8          7.46µs ± 2%  7.50µs ± 2%     ~     (p=0.131 n=18+20)
LogZerologf-8         12.5µs ± 2%  12.6µs ± 3%     ~     (p=0.430 n=18+19)

Change-Id: I94c571685c87681b64ce9a349b1e037ccdb4a888
Reviewed-on: https://go-review.googlesource.com/c/exp/+/323849
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
3 files changed
tree: a3371c7c7be58576369b267b4b58438cdc6fe62d
  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.