source: doc/theses/colby_parsons_MMAth/benchmarks/actors/ucpp/uC++SendDynamic.cc @ 5adf4f4

ADTast-experimental
Last change on this file since 5adf4f4 was 5adf4f4, checked in by caparson <caparson@…>, 15 months ago

added caf/uC++/proto benchmarks

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#include <iostream>
2using namespace std;
3#include <chrono>
4using namespace chrono;
5#include <uActor.h>
6
7int Times = 100'000'000;                                                                // default values
8time_point<steady_clock> starttime;
9
10struct Msg : public uActor::Message { int cnt; Msg( int cnt ) : Message( uActor::Delete ), cnt( cnt ) {} };
11
12_Actor Send {
13        Allocation receive( Message & msg ) {
14                Case ( Msg, msg ) {
15                        if ( msg_d->cnt >= Times ) {
16                                cout << (steady_clock::now() - starttime).count() / Times << endl;
17                                return Delete;
18                        } // if
19                        //cout << msg_d->cnt << endl;
20                        *(new Send) | *new Msg{ msg_d->cnt + 1 };       // dynamic actor / message send self
21                } // Case
22                return Delete;
23        } // Send:::receive
24}; // Send
25
26int main( int argc, char * argv[] ) {
27        switch ( argc ) {
28          case 2:
29                if ( strcmp( argv[1], "d" ) != 0 ) { Times = stoi( argv[1] ); }
30                if ( Times < 1 ) goto Usage;
31          case 1:                                                                                       // use defaults
32                break;
33          default:
34          Usage:
35                cerr << "Usage: " << argv[0] << " [ times (> 0) ]" << endl;
36                exit( EXIT_FAILURE );
37        } // switch
38
39        uActor::start();                                                                        // start actor system
40        starttime = steady_clock::now();
41        *(new Send) | *new Msg{ 0 };
42        uActor::stop();                                                                         // wait for all actors to terminate
43} // main
44
45// /usr/bin/time -f "%Uu %Ss %Er %Mkb" a.out
46
47// Local Variables: //
48// compile-command: "u++-work -g -Wall -Wextra -O3 -nodebug -DNDEBUG -multi uC++SendDynamic.cc" //
49// End: //
Note: See TracBrowser for help on using the repository browser.