Changes in benchmark/creation/goroutine.go [50cfa99:bf71cfd]
- File:
-
- 1 edited
-
benchmark/creation/goroutine.go (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/creation/goroutine.go
r50cfa99 rbf71cfd 2 2 3 3 import ( 4 "fmt" 5 "time" 6 "os" 7 "strconv" 4 "fmt" 5 "time" 8 6 ) 9 7 … … 19 17 20 18 func main() { 21 var times int = 10000000 22 if len( os.Args ) > 2 { os.Exit( 1 ) } 23 if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) } 24 19 const NoOfTimes = 500000 25 20 start := time.Now() 26 for i := 1; i <= times; i += 1 {21 for i := 1; i <= NoOfTimes; i += 1 { 27 22 go noop() // creation 28 <- shake // wait for completion29 23 } 30 24 end := time.Now() 31 fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) ) 25 fmt.Printf("%d\n", end.Sub(start) / time.Duration(NoOfTimes)) 26 <- shake 32 27 } 33 34 // Local Variables: //35 // tab-width: 4 //36 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.