Last change
on this file was
05956d21,
checked in by caparsons <caparson@…>, 17 months ago
|
refactored benchmarks to use actor bar operator
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[cec2551] | 1 | #include <actor.hfa> |
---|
| 2 | #include <fstream.hfa> |
---|
| 3 | #include <stdlib.hfa> |
---|
| 4 | #include <string.h> |
---|
| 5 | #include <stdio.h> |
---|
| 6 | #include "bench.hfa" |
---|
| 7 | |
---|
| 8 | int Times = 1000000; // default values |
---|
| 9 | |
---|
| 10 | struct derived_actor { |
---|
| 11 | inline actor; |
---|
| 12 | }; |
---|
| 13 | |
---|
| 14 | struct derived_msg { |
---|
| 15 | inline message; |
---|
| 16 | int cnt; |
---|
| 17 | }; |
---|
| 18 | |
---|
| 19 | static inline void ?{}( derived_msg & this, int cnt ) { |
---|
| 20 | ((message &) this){ Delete }; |
---|
| 21 | this.cnt = cnt; |
---|
| 22 | } |
---|
| 23 | static inline void ?{}( derived_msg & this ) { this{ 0 }; } |
---|
| 24 | |
---|
| 25 | uint64_t start_time; |
---|
[84334d0] | 26 | allocation receive( derived_actor & receiver, derived_msg & msg ) { |
---|
[cec2551] | 27 | if ( msg.cnt >= Times ) { |
---|
| 28 | printf("%.2f\n", ((double)(bench_time() - start_time)) / ((double)Times) ); // ns |
---|
| 29 | return Delete; |
---|
| 30 | } |
---|
| 31 | derived_msg * d_msg = malloc(); |
---|
| 32 | (*d_msg){ msg.cnt + 1 }; |
---|
| 33 | derived_actor * d_actor = malloc(); |
---|
| 34 | (*d_actor){}; |
---|
[05956d21] | 35 | *d_actor | *d_msg; |
---|
[cec2551] | 36 | return Delete; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | int main( int argc, char * argv[] ) { |
---|
| 40 | switch ( argc ) { |
---|
| 41 | case 2: |
---|
| 42 | if ( strcmp( argv[1], "d" ) != 0 ) { // default ? |
---|
| 43 | Times = atoi( argv[1] ); |
---|
| 44 | if ( Times < 1 ) goto Usage; |
---|
| 45 | } // if |
---|
| 46 | case 1: // use defaults |
---|
| 47 | break; |
---|
| 48 | default: |
---|
| 49 | Usage: |
---|
| 50 | sout | "Usage: " | argv[0] | " [ times (> 0) ]"; |
---|
| 51 | exit( EXIT_FAILURE ); |
---|
| 52 | } // switch |
---|
| 53 | |
---|
| 54 | executor e{ 0, 1, 1, false, 1 }; |
---|
| 55 | |
---|
| 56 | start_actor_system( e ); |
---|
| 57 | |
---|
| 58 | start_time = bench_time(); |
---|
| 59 | |
---|
| 60 | derived_msg * d_msg = malloc(); |
---|
| 61 | (*d_msg){}; |
---|
| 62 | derived_actor * d_actor = malloc(); |
---|
| 63 | (*d_actor){}; |
---|
[05956d21] | 64 | *d_actor | *d_msg; |
---|
[cec2551] | 65 | |
---|
| 66 | |
---|
| 67 | stop_actor_system(); |
---|
| 68 | |
---|
| 69 | // uint64_t end_time = bench_time(); |
---|
| 70 | |
---|
| 71 | // printf("%.2f\n", ((double)(end_time - start_time))*((double)1e-9) ); // s |
---|
| 72 | |
---|
| 73 | // printf("%.2f\n", ((double)(end_time - start_time)) / ((double)Times) ); // ns |
---|
| 74 | |
---|
| 75 | return 0; |
---|
| 76 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.