Last change
on this file since daf4c89 was
cd477ca,
checked in by caparsons <caparson@…>, 18 months ago
|
renamed baseline bench and added separate cluster to cfa benchmark to avoid main thread starvation issue
|
-
Property mode set to
100644
|
File size:
868 bytes
|
Rev | Line | |
---|
[6e6989c] | 1 | #include <locks.hfa> |
---|
| 2 | #include <mutex_stmt.hfa> |
---|
| 3 | #include <stdio.h> |
---|
| 4 | |
---|
| 5 | #include "../bench.h" |
---|
| 6 | |
---|
| 7 | test_spinlock LOCKS; |
---|
| 8 | |
---|
| 9 | bool done = false; |
---|
| 10 | uint64_t total = 0; |
---|
| 11 | thread worker {}; |
---|
[cd477ca] | 12 | static inline void ?{}( worker & this, cluster & clu ) { |
---|
| 13 | ((thread &)this){ clu }; |
---|
| 14 | } |
---|
[6e6989c] | 15 | void main( worker & w ) { |
---|
| 16 | BENCH( mutex ( LOCKS ) { }, total, done ) |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | int main( int argc, char * argv[] ) { |
---|
| 20 | BENCH_START() |
---|
[cd477ca] | 21 | cluster clus; |
---|
| 22 | processor * proc[threads]; |
---|
| 23 | for ( i; threads ) // create procs |
---|
| 24 | (*(proc[i] = alloc())){clus}; |
---|
| 25 | |
---|
| 26 | worker * w[threads]; |
---|
| 27 | for ( i; threads ) // create threads |
---|
| 28 | (*(w[i] = alloc())){ clus }; |
---|
| 29 | |
---|
| 30 | sleep( 10`s ); |
---|
| 31 | done = true; |
---|
| 32 | |
---|
| 33 | for ( i; threads ) // delete threads |
---|
| 34 | delete(w[i]); |
---|
| 35 | |
---|
| 36 | for ( i; threads ) // delete procs |
---|
| 37 | delete(proc[i]); |
---|
[6e6989c] | 38 | printf( "%lu\n", total ); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | // Local Variables: // |
---|
| 42 | // tab-width: 4 // |
---|
| 43 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.