Skip to content

Instantly share code, notes, and snippets.

@mipearson
Created November 8, 2014 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mipearson/31cb27352112cb44c3da to your computer and use it in GitHub Desktop.
Save mipearson/31cb27352112cb44c3da to your computer and use it in GitHub Desktop.
# serve is via a simple net.HTTP go server
# cmd is running the binary and piping stdin/out
# serve maxes out at 3000/s, cmd at 130/s regardless of input
# npm.sh.raw is 5000 lines of coloured npm install output and is
# more representative of the sorts of inputs buildbox would be dealing with
➜ terminal git:(GoRewrite) ✗ ./script/benchmark spec/fixtures/npm.sh.raw
2014/11/08 13:44:47 Listening on port 1337
Calculating -------------------------------------
npm.sh.raw ruby 1 i/100ms
npm.sh.raw go serve 1 i/100ms
npm.sh.raw go cmd 1 i/100ms
-------------------------------------------------
npm.sh.raw ruby 0.8 (±0.0%) i/s - 4 in 5.153145s
npm.sh.raw go serve 10.8 (±9.2%) i/s - 54 in 5.003026s
npm.sh.raw go cmd 10.3 (±0.0%) i/s - 52 in 5.054219s
➜ terminal git:(GoRewrite) ✗ ./script/benchmark spec/fixtures/pikachu.sh.raw
2014/11/08 13:47:28 Listening on port 1337
Calculating -------------------------------------
pikachu.sh.raw ruby 1 i/100ms
pikachu.sh.raw gosrv 16 i/100ms
pikachu.sh.raw gocmd 8 i/100ms
-------------------------------------------------
pikachu.sh.raw ruby 20.0 (±5.0%) i/s - 100 in 5.020817s
pikachu.sh.raw gosrv 169.2 (±4.7%) i/s - 848 in 5.022955s
pikachu.sh.raw gocmd 82.3 (±1.2%) i/s - 416 in 5.052944s
➜ terminal git:(GoRewrite) ✗ go test -bench . -benchmem
PASS
BenchmarkRendererControl 1000000 2365 ns/op 1598 B/op 11 allocs/op
BenchmarkRendererCurl 50000 31670 ns/op 9807 B/op 51 allocs/op
BenchmarkRendererHomer 50000 64634 ns/op 39245 B/op 192 allocs/op
BenchmarkRendererPikachu 500 4244408 ns/op 1119555 B/op 16677 allocs/op
BenchmarkRendererNpm 20 72910622 ns/op 28721122 B/op 262893 allocs/op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment