Benchmarks should be honest and not overclaim.
Run:
go test -bench=. -benchmem ./...For more stable local numbers, run multiple samples:
go test -run='^$' -bench=. -benchmem -count=5 ./...- Plain channel send/recv same goroutine.
chanprobe.QueueSend/Recv same goroutine.- Plain channel producer/consumer.
chanprobe.Queueproducer/consumer.- TrySend/TryRecv.
- Snapshot under load.
Compare related pairs:
BenchmarkChannelSameGoroutinevsBenchmarkQueueSameGoroutineBenchmarkChannelProducerConsumervsBenchmarkQueueProducerConsumer
Native channels are the baseline. chanprobe.Queue is expected to cost more
because it tracks counters, wait durations, item age, close state, and supports
context-aware blocking operations.
BenchmarkQueueTrySendTryRecv measures the non-blocking fast path.
BenchmarkQueueSnapshot measures the cost of reading observability data from a
populated queue.
Example local result on an AMD Ryzen 3 4300U:
BenchmarkChannelSameGoroutine-4 30.80 ns/op 0 B/op 0 allocs/op
BenchmarkQueueSameGoroutine-4 2293 ns/op 0 B/op 0 allocs/op
BenchmarkChannelProducerConsumer-4 51.11 ns/op 0 B/op 0 allocs/op
BenchmarkQueueProducerConsumer-4 2389 ns/op 0 B/op 0 allocs/op
BenchmarkQueueTrySendTryRecv-4 2262 ns/op 0 B/op 0 allocs/op
BenchmarkQueueSnapshot-4 1164 ns/op 0 B/op 0 allocs/op
Treat these as local reference numbers, not a universal performance claim.
Do not claim chanprobe is faster than channels.
Expected positioning:
chanprobeadds observability and context-aware queue operations. It has overhead compared to native channels. Use it at important async boundaries where visibility matters.