Last change
on this file since ea10f64 was
5adf4f4,
checked in by caparson <caparson@…>, 21 months ago
|
added caf/uC++/proto benchmarks
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | #include <iostream> |
---|
2 | using namespace std; |
---|
3 | #include <chrono> |
---|
4 | using namespace chrono; |
---|
5 | #include <uActor.h> |
---|
6 | |
---|
7 | int Times = 100'000'000; // default values |
---|
8 | time_point<steady_clock> starttime; |
---|
9 | |
---|
10 | struct 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 | |
---|
26 | int 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.