source: doc/theses/colby_parsons_MMAth/benchmarks/actors/cfa/static.cfa @ b09ca2b

ast-experimental
Last change on this file since b09ca2b was 4066bd2, checked in by caparson <caparson@…>, 20 months ago

added timing header and cleaned up benchmarks

  • Property mode set to 100644
File size: 1.4 KB
Line 
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
8int Times = 1000000;                                                            // default values
9
10struct derived_actor {
11    inline actor;
12};
13
14struct derived_msg {
15    inline message;
16    int cnt;
17};
18
19static inline void ?{}( derived_msg & this, int cnt ) {
20    this.cnt = cnt;
21}
22static inline void ?{}( derived_msg & this ) { this{ 0 }; }
23
24uint64_t start_time;
25Allocation receive( derived_actor & receiver, derived_msg & msg ) {
26    if ( msg.cnt >= Times ) {
27        printf("%.2f\n", ((double)(bench_time() - start_time)) / ((double)Times) ); // ns
28        return Finished;
29    }
30    msg.cnt++;
31    receiver << msg;
32    return Nodelete;
33}
34
35int main( int argc, char * argv[] ) {
36    switch ( argc ) {
37          case 2:
38                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
39                        Times = atoi( argv[1] );
40                        if ( Times < 1 ) goto Usage;
41                } // if
42          case 1:                                                                                       // use defaults
43                break;
44          default:
45          Usage:
46                sout | "Usage: " | argv[0] | " [ times (> 0) ]";
47                exit( EXIT_FAILURE );
48        } // switch
49
50    executor e{ 0, 1, 1, false, 1 };
51   
52    start_actor_system( e );
53
54    start_time = bench_time();
55
56    derived_msg msg;
57
58    derived_actor actor;
59
60    actor << msg;
61
62    stop_actor_system();
63   
64    // uint64_t end_time = bench_time();
65
66    // printf("%.2f\n", ((double)(end_time - start_time))*((double)1e-9) ); // s
67
68    return 0;
69}
Note: See TracBrowser for help on using the repository browser.