News for hackers. Stuff that matters.
Re:Show HN: State Trooper – Tiny, no frills state machine fo... by klabb3 on Saturday June 17, 2023 @05:05PM (#36374593)
I saw the benchmark which seemed crazy (3us per transition and allocations). So looked quickly at the code.

Recommend putting the tracking of previous states in a separate optional debugging type so you don’t have to pay the cost in general. Oh and using time stamps as a key is kinda weird, but even weirder in Go where maps are non-deterministically enumerable.

Otherwise, seems like a good use of generics, given Golangs particular take on it.

Re:Show HN: State Trooper – Tiny, no frills state machine fo... by hishamk on Sunday June 18, 2023 @05:15AM (#36378560)
Thanks for the feedback.

The benchmark was for six transitions. I've now updated a few things and added new benchmarks.

I also got rid of timestamps for the map keys - it's back to a regular slice. In retrospect, that was a tad bit off, I agree.