@@ -32,12 +32,9 @@ const demSetPath = csDemosPath + "/set"
3232const defaultDemPath = csDemosPath + "/default.dem"
3333const unexpectedEndOfDemoPath = csDemosPath + "/unexpected_end_of_demo.dem"
3434
35- var concurrentDemos int
35+ var concurrentDemos = flag . Int ( "concurrentdemos" , 2 , "The `number` of current demos" )
3636
3737func init () {
38- flag .IntVar (& concurrentDemos , "concurrentdemos" , 2 , "The `number` of current demos" )
39- flag .Parse ()
40-
4138 if _ , err := os .Stat (defaultDemPath ); err != nil {
4239 panic (fmt .Sprintf ("Failed to read test demo %q" , defaultDemPath ))
4340 }
@@ -220,7 +217,7 @@ func TestConcurrent(t *testing.T) {
220217 t .Skip ("skipping test" )
221218 }
222219
223- t .Logf ("Running concurrency test with %d demos\n " , concurrentDemos )
220+ t .Logf ("Running concurrency test with %d demos\n " , * concurrentDemos )
224221
225222 var i int64
226223 runner := func () {
@@ -249,7 +246,7 @@ func parseDefaultDemo(tb testing.TB) {
249246
250247func runConcurrently (runner func ()) {
251248 var wg sync.WaitGroup
252- for i := 0 ; i < concurrentDemos ; i ++ {
249+ for i := 0 ; i < * concurrentDemos ; i ++ {
253250 wg .Add (1 )
254251 go func () { runner (); wg .Done () }()
255252 }
@@ -313,7 +310,7 @@ func BenchmarkInMemory(b *testing.B) {
313310}
314311
315312func BenchmarkConcurrent (b * testing.B ) {
316- b .Logf ("Running concurrency benchmark with %d demos\n " , concurrentDemos )
313+ b .Logf ("Running concurrency benchmark with %d demos\n " , * concurrentDemos )
317314
318315 for i := 0 ; i < b .N ; i ++ {
319316 runConcurrently (func () { parseDefaultDemo (b ) })
0 commit comments