如何使用標誌選項與gocheck測試框架進行基準測試?在我提供的鏈接中,似乎他們提供的唯一示例是運行go test -check.b
,但是它們不提供關於它如何工作的額外評論,因此很難使用它。當我做了go help test
以及我做了go help testflag
時,我甚至找不到「go-document」文件。我特別想知道如何更好的使用基準測試框架和控制多久它運行或爲它多少次迭代運行的等等等等,例如,在例如它們提供:如何使用golang(gitck)gocheck測試框架的基準標誌?
func (s *MySuite) BenchmarkLogic(c *C) {
for i := 0; i < c.N; i++ {
// Logic to benchmark
}
}
還有就是變量cN如何指定該變量?它是通過實際的程序本身,還是通過測試及其標誌或命令行?
在側面說明,從go help testflag
文檔也談-bench regex
,benchmem
和benchtime t
選項,但是,它並沒有談論-check.b
選項。然而,我確實試圖按照那裏描述的方式運行這些選項,但它並沒有真正做我能注意到的任何事情。 gocheck是否與go test
的原始選項一起使用?
我看到的主要問題是沒有關於如何使用gocheck工具或其命令的明確文檔。我不小心給它一個錯誤的標誌,它給我一個錯誤信息提示我需要(這有限的說明)有用的命令:
-check.b=false: Run benchmarks
-check.btime=1s: approximate run time for each benchmark
-check.f="": Regular expression selecting which tests and/or suites to run
-check.list=false: List the names of all tests that will be run
-check.v=false: Verbose mode
-check.vv=false: Super verbose mode (disables output caching)
-check.work=false: Display and do not remove the test working directory
-gocheck.b=false: Run benchmarks
-gocheck.btime=1s: approximate run time for each benchmark
-gocheck.f="": Regular expression selecting which tests and/or suites to run
-gocheck.list=false: List the names of all tests that will be run
-gocheck.v=false: Verbose mode
-gocheck.vv=false: Super verbose mode (disables output caching)
-gocheck.work=false: Display and do not remove the test working directory
-test.bench="": regular expression to select benchmarks to run
-test.benchmem=false: print memory allocations for benchmarks
-test.benchtime=1s: approximate run time for each benchmark
-test.blockprofile="": write a goroutine blocking profile to the named file after execution
-test.blockprofilerate=1: if >= 0, calls runtime.SetBlockProfileRate()
-test.coverprofile="": write a coverage profile to the named file after execution
-test.cpu="": comma-separated list of number of CPUs to use for each test
-test.cpuprofile="": write a cpu profile to the named file during execution
-test.memprofile="": write a memory profile to the named file after execution
-test.memprofilerate=0: if >=0, sets runtime.MemProfileRate
-test.outputdir="": directory in which to write profiles
-test.parallel=1: maximum test parallelism
-test.run="": regular expression to select tests and examples to run
-test.short=false: run smaller test suite to save time
-test.timeout=0: if positive, sets an aggregate time limit for all tests
-test.v=false: verbose: print additional output
被寫入錯誤的命令獲得一些幫助,這個工具的唯一途徑?它沒有幫助標誌或什麼?
請修改'''去測試-check.b = '''用'''去測試--check.b'''或'''去測試--gocheck.b''' – hoenir