2

I am looking for some tools or the Go tests package to run some benchmarks on different servers. Any idea how i get some nice profiling output in my console. Is it possible to simulate multiple users visiting the server?

getting no output at from this testing code

package tests

import(
 "testing"
 )


func BenchmarkMyFunc(b *testing.B) {
  for i := 0; i < b.N; i++ {
   testplus()
  }
}

func testplus() int {
 x := 1
 return x + 1
}

thank you

user3396016
  • 119
  • 1
  • 10
  • How do you invoke `go test`? – nemo Jul 19 '14 at 19:54
  • Whatever solution you end up using, be aware of http://blogs.perl.org/users/steffen_mueller/2010/09/your-benchmarks-suck.html, mentioned in https://groups.google.com/forum/#!topic/golang-nuts/Y2zj01FGUK0 – VonC Jul 19 '14 at 19:56
  • and you have replaced RE with an actual regular expression? E.g. `go test -bench=.` if you want to run all tests or `go test -bench=MyFunc` for example? – tux21b Jul 19 '14 at 20:11

1 Answers1

6

Use Go's built-in profiling tools, or convenience wrappers around them: http://dave.cheney.net/2013/07/07/introducing-profile-super-simple-profiling-for-go-programs

... and then hit the application with a decent HTTP load testing tool to generate load: https://github.com/wg/wrk

Note that:

  • Profiling will show you what to actually optimize, but don't go overboard.
  • HTTP load testing results are only applicable to your application and machine combination
  • In many cases, you may be restricted by your networking stack configuration.

You can also include benchmarks in your test code, noting that these are typically useful for benchmarking algorithms/comparing approaches rather than whole-of-application performance.

elithrar
  • 23,364
  • 10
  • 85
  • 104