Documentation ¶ Index ¶ func DoAndPrint(count int, title string, loop func()) func DoParallelAndPrint(concurrent int, count int, title string, loop func()) func SpentTime(msg string, f func()) time.Duration type Result func Do(count int, loop func()) Result func DoParallel(concurrent int, count int, loop func()) Result Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ func DoAndPrint ¶ func DoAndPrint(count int, title string, loop func()) 执行测试并打印结果 func DoParallelAndPrint ¶ func DoParallelAndPrint(concurrent int, count int, title string, loop func()) 并行执行测试并打印结果 func SpentTime ¶ added in v1.7.3 func SpentTime(msg string, f func()) time.Duration 打印执行函数消耗的时间 Types ¶ type Result ¶ type Result struct { Count int `json:"count"` Spent time.Duration `json:"spent"` TPS int `json:"tps"` } func Do ¶ func Do(count int, loop func()) Result 执行测试 func DoParallel ¶ func DoParallel(concurrent int, count int, loop func()) Result 并行执行测试 Source Files ¶ View all Source files benchmark.go util.go Click to show internal directories. Click to hide internal directories.