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.

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

报告相同问题?

悬赏问题

  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?