在Go语言中绘制基准测试结果。

huangapple go评论69阅读模式
英文:

Plot benchmark's result in Go

问题

假设我已经编写了不同的函数来计算斐波那契数列的第n个数字:

func fiboIterative(n int) {
   ...
}

func fiboRecursive(n int) {
   ...
}

我想要获得一个图表,显示每个函数在不同n值下的性能。

到目前为止,我一直在使用内置的testing包进行基准测试,它会将每个操作的时间打印到控制台。是否有一种简单的方法/包可以运行多个n值的基准测试,将结果存储在csv文件或类似的文件中,然后绘制它们的图表?

英文:

Let's say I have written different functions to compute Fibonacci's nth number:

func fiboIterative(n int) {
   ...
}

func fiboRecursive(n int) {
   ...
}

And I'd like to get a chart showing the performances of each function depending on the value of n.

So far, I have been benchmarking using the built-in testing package which prints the time per operations to the console. Is there a simple way/package to run the benchmark for multiple values of n, stores the result in a csv or something similar and then plot them?

答案1

得分: 1

我本来期望这样的功能会被内置进来...提供一个没有这个功能的基准测试工具确实有些奇怪。

在语言包中包含一个跨平台的绘图库似乎并不明显,这将需要进行维护。

目前,你需要依赖第三方项目来进行基准测试的绘图功能。

例如,项目 aybabtme/benchkit 可以从基准测试生成 svg 绘图。

> 这是一个轻量级、触手可及的基准测试工具包。与标准的 pprof 工具相比,该包旨在帮助生成图表和其他工件。

在Go语言中绘制基准测试结果。

英文:

> I would have expected something like this to be built in... It is weird to provide a benchmarking utility without this

It doesn't seem obvious to include a cross-platform plot library within the language packages, that will have to be maintained.

As it is now, you need to rely on third-party projects for a plot feature for benchmarks.

For example, the project aybabtme/benchkit generates svg plot pictures from benchmarks.

> lightweight, feather touch, benchmarking kit. In comparison to the standard pprof utilities, this package is meant to help generating graphs and other artifacts.

在Go语言中绘制基准测试结果。

huangapple
  • 本文由 发表于 2015年1月20日 18:05:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/28042548.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定