2014-06-26 11 views
7

Come si usano le opzioni flag per i benchmark con il framework di test gocheck? Nel collegamento che ho fornito sembra che l'unico esempio che forniscono sia l'esecuzione di go test -check.b, tuttavia, non forniscono commenti aggiuntivi su come funziona, quindi è difficile utilizzarlo. Non ho nemmeno trovato la documentazione di -check in the go quando ho fatto go help test né quando ho fatto go help testflag. In particolare voglio sapere come utilizzare il framework di test di riferimento migliore e controllare per quanto tempo corre a favore o per quante iterazioni che corre per ecc ecc Per esempio nell'esempio che forniscono:Come si usano i benchmark flags for the go (golang) framework di test del gocheck?

func (s *MySuite) BenchmarkLogic(c *C) { 
    for i := 0; i < c.N; i++ { 
     // Logic to benchmark 
    } 
} 

V'è la variabile cN Come si specifica quella variabile? È attraverso il programma stesso o tramite test di go e le sue flag o la riga di comando?

Sul lato nota, la documentazione da go help testflag ha parlato -bench regex, benchmem e benchtime t opzioni, tuttavia, non parla l'opzione -check.b. Comunque ho provato a eseguire queste opzioni come descritto qui, ma in realtà non ho fatto nulla che potessi notare. Gocheck funziona con le opzioni originali per go test?

Il problema principale che vedo è che non esiste una documentazione chiara su come utilizzare lo strumento gocheck oi suoi comandi. Ho dato accidentalmente una bandiera sbagliato e mi ha buttato un messaggio di errore che suggerisce comandi utili che ho bisogno (che descrizione limitata):

-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 

sta scrivendo sbagliato comanda l'unico modo per avere un aiuto con questo strumento? non ha una bandiera di aiuto o qualcosa del genere?

risposta

3

vedere il Description_of_testing_flags:

-bench regexp 
    Run benchmarks matching the regular expression. 
    By default, no benchmarks run. To run all benchmarks, 
    use '-bench .' or '-bench=.'. 

-check.b funziona allo stesso modo di -test.bench.

E.g. per eseguire tutti i parametri di riferimento:

go test -check.b=. 

per eseguire un benchmark specifico:

go test -check.b=BenchmarkLogic 

ulteriori informazioni sui test in Go può essere trovato here

+0

si prega di modificare '' 'go prova -check.b = .''' con '' 'vai test --check.b''' o' 'go test --gocheck.b'''' – hoenir

Problemi correlati