duanshan188866 2014-07-19 19:46
浏览 43
已采纳

对我的Golang Web服务器进行基准测试

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

  • 写回答

1条回答 默认 最新

  • duanqiao2006 2014-07-20 00:15
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗