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)
| 45 | // plumbing. Useful for tracking per-event allocation behavior on the |
| 46 | // SubscribeFunc dispatch path. |
| 47 | func 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 | |
| 63 | func BenchmarkSubsThroughput(b *testing.B) { |
| 64 | bus := eventbus.New() |