Playing with Go1.1beta2, it's much faster!
One month ago I wrote some benchmarks for my Go-UrlRouter package. Yesterday Go1.1beta2 has been released, lets see how much faster it is for this particular project.
go-urlrouter$ go test -bench ".*" PASS BenchmarkNoCompression 50000 43049 ns/op BenchmarkCompression 100000 25114 ns/op BenchmarkRegExpLoop 2000 1090131 ns/op ok github.com/ant0ine/go-urlrouter 7.748s
go-urlrouter$ /usr/local/go/bin/go test -bench ".*" PASS BenchmarkNoCompression 100000 27635 ns/op BenchmarkCompression 100000 19632 ns/op BenchmarkRegExpLoop 2000 1001683 ns/op ok github.com/ant0ine/go-urlrouter 7.419s
That gives us:
BenchmarkNoCompression 36% less time BenchmarkCompression 22% less time BenchmarkRegExpLoop 8% less time
The Trie implementation makes a heavy use of “maps” (especially when not compressed). 36% less time in this case! Impressive! For the implementation based on RegExp, the improvement is less significant.
Also note that with Go1.1beta2 the Trie based solution (compressed) is now 50 times faster than the RegExp based solution. (previously 40 times)
Go comes with a nice utility to compare the benchmark outputs. Thanks @bradfitz for the info!
go-urlrouter$ /usr/local/go/misc/benchcmp 1.0.3.txt 1.1.txt benchmark old ns/op new ns/op delta BenchmarkNoCompression 43049 27635 -35.81% BenchmarkCompression 25114 19632 -21.83% BenchmarkRegExpLoop 1090131 1001683 -8.11%