Skip to content

Instantly share code, notes, and snippets.

View superloach's full-sized avatar
🍜
ramen is good

Terra Brown superloach

🍜
ramen is good
View GitHub Profile
@superloach
superloach / README.md
Last active December 31, 2020 23:59
golang bit flag benchmarks

this is a simple test of performance for checking if a uint8 (commonly used for bit flags) is non-zero.

  • u > 0 is the slowest, averaging 1.14ns/op.
  • u != 0 is a little faster, averaging 1.13ns/op.
  • casting u to bool is the fastest, averaging 0.98ns/op.

note: the third method is unsafe, and only confirmed to work on linux/amd64, where a non-zero byte is truthy.

@superloach
superloach / README.md
Last active January 1, 2021 05:12
dismock gateway testing

this is a very basic example that swaps the ws connection in dismock for one that allows mocking events. it then tests this by sending a status update and comparing results.

everything (hello, ready, event parsing) is done manually right now, but the general idea is that we can mock all the gateway events, both incoming and outgoing.