MCPcopy
hub / github.com/tailscale/tailscale / BenchmarkBasicFuncThroughput

Function BenchmarkBasicFuncThroughput

util/eventbus/bench_test.go:47–61  ·  view source on GitHub ↗

BenchmarkBasicFuncThroughput is the SubscribeFunc analogue of BenchmarkBasicThroughput: one publisher and one SubscribeFunc callback, shoveling events as fast as they can through the plumbing. Useful for tracking per-event allocation behavior on the SubscribeFunc dispatch path.

(b *testing.B)

Source from the content-addressed store, hash-verified

45// plumbing. Useful for tracking per-event allocation behavior on the
46// SubscribeFunc dispatch path.
47func BenchmarkBasicFuncThroughput(b *testing.B) {
48 bus := eventbus.New()
49 pcli := bus.Client(b.Name() + "-pub")
50 scli := bus.Client(b.Name() + "-sub")
51
52 type emptyEvent [0]byte
53
54 pub := eventbus.Publish[emptyEvent](pcli)
55 eventbus.SubscribeFunc(scli, func(emptyEvent) {})
56
57 for b.Loop() {
58 pub.Publish(emptyEvent{})
59 }
60 bus.Close()
61}
62
63func BenchmarkSubsThroughput(b *testing.B) {
64 bus := eventbus.New()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
SubscribeFuncFunction · 0.92
ClientMethod · 0.65
NameMethod · 0.65
CloseMethod · 0.65
PublishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…