ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since c93fd72 was
b4107c8,
checked in by Peter A. Buhr <pabuhr@…>, 4 years ago
|
update existing benchmarks for changes to bench.h, add new benchmarks in new programming languages
|
-
Property mode set to
100644
|
File size:
731 bytes
|
Rev | Line | |
---|
[50abab9] | 1 | package main |
---|
| 2 | |
---|
| 3 | import ( |
---|
| 4 | "fmt" |
---|
| 5 | "time" |
---|
[b4107c8] | 6 | "flag" |
---|
| 7 | "runtime" |
---|
[50abab9] | 8 | ) |
---|
| 9 | |
---|
| 10 | //======================================= |
---|
| 11 | // time context switch |
---|
| 12 | //======================================= |
---|
| 13 | |
---|
| 14 | var shake chan bool = make( chan bool ) |
---|
| 15 | |
---|
| 16 | func ContextSwitch(N int) { |
---|
| 17 | start := time.Now() |
---|
| 18 | for i := 1; i <= N; i += 1 { |
---|
| 19 | runtime.Gosched() |
---|
| 20 | } |
---|
| 21 | end := time.Now() |
---|
| 22 | fmt.Printf("%d\n", end.Sub(start) / time.Duration(N)) |
---|
| 23 | shake <- true // indicate completion |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | //======================================= |
---|
| 27 | // benchmark driver |
---|
| 28 | //======================================= |
---|
| 29 | |
---|
| 30 | func main() { |
---|
[b4107c8] | 31 | times := flag.Int( "times", 10000000, "loop iterations" ) |
---|
| 32 | go ContextSwitch( *times ) // context switch |
---|
[50abab9] | 33 | <- shake |
---|
| 34 | } |
---|
[b4107c8] | 35 | |
---|
| 36 | // Local Variables: // |
---|
| 37 | // tab-width: 4 // |
---|
| 38 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.