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.

For now, I just initialize them in the BenchmarkExt1, etc functions and
reset the timer, such as the following, but they run sequentially:
func BenchmarkExt1Has(b *testing.B) {

func BenchmarkExt2Has(b *testing.B) {

I dont think it is possible, but I ask just in case :).

Le mardi 22 septembre 2015 19:43:47 UTC+2, Jan Mercl a écrit :

On Tue, Sep 22, 2015, 19:29 <pierre...@gmail.com <javascript:>> wrote:

Declare test flags in your foo_test.go at pkg level:

var x = flag.Bool(...)

Do not call flag.Parse in the test file. No need for TestMain either.

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


Follow ups

Related Discussions

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



site design / logo © 2021 Grokbase