user3396016
user3396016

Reputation: 119

Benchmarking my Golang webserver

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

Upvotes: 2

Views: 8167

Answers (1)

elithrar
elithrar

Reputation: 24300

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.

Upvotes: 6

Related Questions