ADT
arm-eh
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
pthread-emulation
qualifiedEnum
stuck-waitfor-destruct
|
Last change
on this file since b4107c8 was b4107c8, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago |
|
update existing benchmarks for changes to bench.h, add new benchmarks in new programming languages
|
-
Property mode
set to
100644
|
|
File size:
602 bytes
|
| Line | |
|---|
| 1 | package main
|
|---|
| 2 |
|
|---|
| 3 | import (
|
|---|
| 4 | "fmt"
|
|---|
| 5 | "time"
|
|---|
| 6 | "flag"
|
|---|
| 7 | )
|
|---|
| 8 |
|
|---|
| 9 | var shake chan bool = make( chan bool )
|
|---|
| 10 |
|
|---|
| 11 | func noop() {
|
|---|
| 12 | shake <- true // indicate completion
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | //=======================================
|
|---|
| 16 | // benchmark driver
|
|---|
| 17 | //=======================================
|
|---|
| 18 |
|
|---|
| 19 | func main() {
|
|---|
| 20 | times := flag.Int( "times", 500000, "loop iterations" )
|
|---|
| 21 | flag.Parse()
|
|---|
| 22 | start := time.Now()
|
|---|
| 23 | for i := 1; i <= *times; i += 1 {
|
|---|
| 24 | go noop() // creation
|
|---|
| 25 | <- shake // wait for completion
|
|---|
| 26 | }
|
|---|
| 27 | end := time.Now()
|
|---|
| 28 | fmt.Printf( "%d\n", end.Sub(start) / time.Duration(*times) )
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | // Local Variables: //
|
|---|
| 32 | // tab-width: 4 //
|
|---|
| 33 | // End: //
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.