source: benchmark/mutex/goroutine.go @ 2316525

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 2316525 was 50cfa99, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

change Go command-line code to behave like C

  • Property mode set to 100644
File size: 487 bytes
Line 
1package main
2
3import (
4        "fmt"
5        "time"
6        "os"
7        "strconv"
8        "sync"
9)
10
11var mutex sync.Mutex
12
13func call() {
14         mutex.Lock();
15         mutex.Unlock();
16}
17func main() {
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
22        start := time.Now()
23        for i := 1; i <= times; i += 1 {
24                call();
25        }
26        end := time.Now()
27        fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) )
28}
29
30// Local Variables: //
31// tab-width: 4 //
32// End: //
Note: See TracBrowser for help on using the repository browser.