source: benchmark/creation/goroutine.go @ 96f5b30

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 96f5b30 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: 660 bytes
Line 
1package main
2
3import (
4        "fmt"
5        "time"
6        "os"
7        "strconv"
8)
9
10var shake chan bool = make( chan bool )
11
12func noop() {
13        shake <- true   // indicate completion
14}
15
16//=======================================
17// benchmark driver
18//=======================================
19
20func 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
25        start := time.Now()
26        for i := 1; i <= times; i += 1 {
27                go noop()               // creation
28                <- shake                // wait for completion
29        }
30        end := time.Now()
31        fmt.Printf( "%d\n", end.Sub(start) / time.Duration(times) )
32}
33
34// Local Variables: //
35// tab-width: 4 //
36// End: //
Note: See TracBrowser for help on using the repository browser.