我正在寻找一些工具或Go测试包来在不同的服务器上运行一些基准测试.知道如何在我的控制台中获得一些很好的分析输出.是否可以模拟访问服务器的多个用户?
从这个测试代码中得不到输出
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
}
Run Code Online (Sandbox Code Playgroud)
谢谢
使用Go的内置分析工具或它们周围的便利包装:http://dave.cheney.net/2013/07/07/introducing-profile-super-simple-profiling-for-go-programs
...然后用一个不错的HTTP负载测试工具点击应用程序来生成负载:https://github.com/wg/wrk
注意:
您还可以在测试代码中包含基准测试,并指出这些测试代码通常可用于基准算法/比较方法而非整个应用程序性能.