Changeset 50cfa99 for benchmark/mutex
- Timestamp:
- Jan 9, 2020, 5:06:29 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 51493a4, 6b6a3b8
- Parents:
- c93fd72
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified benchmark/mutex/goroutine.go ¶
rc93fd72 r50cfa99 2 2 3 3 import ( 4 "fmt" 5 "time" 6 "flag" 7 "sync" 4 "fmt" 5 "time" 6 "os" 7 "strconv" 8 "sync" 8 9 ) 9 10 … … 11 12 12 13 func call() { 13 14 14 mutex.Lock(); 15 mutex.Unlock(); 15 16 } 16 17 func main() { 17 times := flag.Int( "times", 10000000, "loop iterations" ) 18 flag.Parse() 18 var times int = 10000000 19 if len( os.Args ) > 2 { os.Exit( 1 ) } 20 if len( os.Args ) == 2 { times, _ = strconv.Atoi(os.Args[1]) } 21 19 22 start := time.Now() 20 for i := 1; i <= *times; i += 1 {23 for i := 1; i <= times; i += 1 { 21 24 call(); 22 25 } 23 26 end := time.Now() 24 fmt.Printf( "%d\n", end.Sub(start) / time.Duration( *times) )27 fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) ) 25 28 } 26 29
Note: See TracChangeset
for help on using the changeset viewer.