dqy0707 2014-10-06 10:42
浏览 13
已采纳

进行基准测试如何运作

I've got my Go benchmark working with my API calls but I'm not exactly sure what it means below:

$ go test intapi -bench=. -benchmem -cover -v -cpuprofile=cpu.out
=== RUN TestAuthenticate
--- PASS: TestAuthenticate (0.00 seconds)
PASS
BenchmarkAuthenticate      20000            105010 ns/op            3199 B/op         49 allocs/op
coverage: 0.0% of statements
ok      intapi  4.349s

How does it know how many calls it should make? I do have a loop with b.N as size of the loop but how does Golang know how many to run?

Also I now have cpu profile file. How can I use this to view it?

  • 写回答

1条回答 默认 最新

  • douao2019 2014-10-06 11:07
    关注

    From TFM:

    The benchmark function must run the target code b.N times. The benchmark package will vary b.N until the benchmark function lasts long enough to be timed reliably.

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

报告相同问题?

悬赏问题

  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误