FAQ

On Tuesday, September 22, 2015 at 2:56:20 PM UTC-4, pierre...@gmail.com wrote:

Hmm. Thanks for the answers but I knew this, and this is not what I am
after :).


If I run the following command:
go test -bench Ext

I want to know within my _test.go file if I have the -bench flag and the
value passed with it, i.e. the arguments to "go test", not to my program.

Basically I want to know if I need to initialize my data structures for
benchmarks. I have a couple of them so I would like to run them in separate
goroutines and only if I need them.

In TestMain if you have one, or init(), you can use:

bench := flag.CommandLine.Lookup("test.bench")
if bench.Value.String() != "" {
fmt.Println("bench was set")
}




--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 6 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 22, '15 at 5:29p
activeSep 22, '15 at 8:34p
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase