ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 8e27ac45 was
8e27ac45,
checked in by Thierry Delisle <tdelisle@…>, 4 years ago
|
Fixed benchmark to use getTimeNsec
|
-
Property mode set to
100644
|
File size:
929 bytes
|
Rev | Line | |
---|
[2649ff9] | 1 | #pragma once |
---|
| 2 | |
---|
| 3 | #include <assert.h> |
---|
| 4 | #include <kernel.hfa> |
---|
| 5 | #include <thread.hfa> |
---|
| 6 | |
---|
| 7 | struct cluster * the_benchmark_cluster = 0p; |
---|
| 8 | struct BenchCluster { |
---|
| 9 | cluster self; |
---|
| 10 | }; |
---|
| 11 | |
---|
[9791ab5] | 12 | void ?{}( BenchCluster & this, int flags ) { |
---|
| 13 | (this.self){ "Benchmark Cluster", flags }; |
---|
[2649ff9] | 14 | |
---|
| 15 | assert( the_benchmark_cluster == 0p ); |
---|
| 16 | the_benchmark_cluster = &this.self; |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | struct BenchProc { |
---|
| 20 | processor self; |
---|
| 21 | }; |
---|
| 22 | |
---|
| 23 | void ?{}( BenchProc & this ) { |
---|
| 24 | assert( the_benchmark_cluster != 0p ); |
---|
| 25 | (this.self){ "Benchmark Processor", *the_benchmark_cluster }; |
---|
| 26 | } |
---|
| 27 | |
---|
[9791ab5] | 28 | void wait(double duration, Time & start, Time & end, bool is_tty) { |
---|
| 29 | for() { |
---|
[c953163] | 30 | sleep(100`ms); |
---|
[8e27ac45] | 31 | end = getTimeNsec(); |
---|
| 32 | Duration delta = end - start; |
---|
[9791ab5] | 33 | if(is_tty) { |
---|
[8e27ac45] | 34 | printf("\r%.1f", delta`ds); |
---|
[9791ab5] | 35 | fflush(stdout); |
---|
| 36 | } |
---|
[8e27ac45] | 37 | if( delta >= duration`s ) { |
---|
| 38 | break; |
---|
| 39 | } |
---|
[9791ab5] | 40 | } |
---|
| 41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.