#include #include #include #include #include #include "bench.hfa" int Times = 1000000; // default values struct derived_actor { inline actor; }; struct derived_msg { inline message; int cnt; }; static inline void ?{}( derived_msg & this, int cnt ) { ((message &) this){ Delete }; this.cnt = cnt; } static inline void ?{}( derived_msg & this ) { this{ 0 }; } uint64_t start_time; Allocation receive( derived_actor & receiver, derived_msg & msg ) { if ( msg.cnt >= Times ) { printf("%.2f\n", ((double)(bench_time() - start_time)) / ((double)Times) ); // ns return Delete; } derived_msg * d_msg = malloc(); (*d_msg){ msg.cnt + 1 }; derived_actor * d_actor = malloc(); (*d_actor){}; *d_actor << *d_msg; return Delete; } int main( int argc, char * argv[] ) { switch ( argc ) { case 2: if ( strcmp( argv[1], "d" ) != 0 ) { // default ? Times = atoi( argv[1] ); if ( Times < 1 ) goto Usage; } // if case 1: // use defaults break; default: Usage: sout | "Usage: " | argv[0] | " [ times (> 0) ]"; exit( EXIT_FAILURE ); } // switch executor e{ 0, 1, 1, false, 1 }; start_actor_system( e ); start_time = bench_time(); derived_msg * d_msg = malloc(); (*d_msg){}; derived_actor * d_actor = malloc(); (*d_actor){}; *d_actor << *d_msg; stop_actor_system(); // uint64_t end_time = bench_time(); // printf("%.2f\n", ((double)(end_time - start_time))*((double)1e-9) ); // s // printf("%.2f\n", ((double)(end_time - start_time)) / ((double)Times) ); // ns return 0; }