source: benchmark/mutex/goroutine.go @ cc7bbe6

ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change on this file since cc7bbe6 was 50cfa99, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

change Go command-line code to behave like C

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