johnnylee/state-machine-benchmarks — pull request #1 by rakoo (2014-10-14 22:21:51+00:00)
Title: Add loop

I believe the good old `for`-`switch` loop is the more idiomatic way to go (haha); in servers you would have `for`-`select` in the same vein. So here's an implementation with that scheme.

The results on my core i5 with go 1.3.1:

```
BenchmarkGotoSimple 5 514757416 ns/op 0 B/op 0 allocs/op
BenchmarkGotoFunctions 1 1304963523 ns/op 0 B/op 0 allocs/op
BenchmarkFuncFunc 1 4829273652 ns/op 0 B/op 0 allocs/op
BenchmarkStructFuncFunc 1 109317307226 ns/op 25555738064 B/op 1502700939 allocs/op
BenchmarkStructFuncFunc2 1 4432866074 ns/op 16 B/op 1 allocs/op
BenchmarkLoop 1 3640792089 ns/op 0 B/op 0 allocs/op
```

Better than all options except `goto`.