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.

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

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思