This might be useful to some if you need a very light pub/sub inside one process.
I was building a small multiplayer game in Go. Started with a channel fan-out but (for no particular reason) wanted to see if we can do better. Put together this tiny event bus to test, and on my i7-13700K it delivers events in 10-40ns, roughly 4-10x faster than the plain channel loop, depending on the configuration.
I was building a small multiplayer game in Go. Started with a channel fan-out but (for no particular reason) wanted to see if we can do better. Put together this tiny event bus to test, and on my i7-13700K it delivers events in 10-40ns, roughly 4-10x faster than the plain channel loop, depending on the configuration.
name time/msg msgs/s allocs/op vs channel -------------------- ------------ ------------ ------------ ------------------ 1x1 36.5 ns 27.4M 0 +4.3x 1x10 14.0 ns 71.7M 0 +11.0x 1x100 12.9 ns 77.6M 0 +6.7x 10x1 22.5 ns 44.5M 0 +7.6x 10x10 12.9 ns 77.3M 0 +7.5x 10x100 11.8 ns 84.7M 0 +6.9x by kelindar 0 minutes ago