package main import ( "fmt" "time" "flag" ) var shake chan bool = make( chan bool ) func noop() { shake <- true // indicate completion } //======================================= // benchmark driver //======================================= func main() { times := flag.Int( "times", 500000, "loop iterations" ) flag.Parse() start := time.Now() for i := 1; i <= *times; i += 1 { go noop() // creation <- shake // wait for completion } end := time.Now() fmt.Printf( "%d\n", end.Sub(start) / time.Duration(*times) ) } // Local Variables: // // tab-width: 4 // // End: //