Last change
on this file since 77fd9fe2 was
5adf4f4,
checked in by caparson <caparson@…>, 18 months ago
|
added caf/uC++/proto benchmarks
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[5adf4f4] | 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 ) : cnt( cnt ) {} } msg{ 0 }; // default Nodelete |
---|
| 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 Finished; |
---|
| 18 | } // if |
---|
| 19 | //cout << msg_d->cnt << endl; |
---|
| 20 | msg_d->cnt += 1; |
---|
| 21 | *this | *msg_d; // static actor / message send self |
---|
| 22 | } // Case |
---|
| 23 | return Nodelete; |
---|
| 24 | } // Send:::receive |
---|
| 25 | }; // Send |
---|
| 26 | |
---|
| 27 | int main( int argc, char * argv[] ) { |
---|
| 28 | switch ( argc ) { |
---|
| 29 | case 2: |
---|
| 30 | if ( strcmp( argv[1], "d" ) != 0 ) { Times = stoi( argv[1] ); } |
---|
| 31 | if ( Times < 1 ) goto Usage; |
---|
| 32 | case 1: // use defaults |
---|
| 33 | break; |
---|
| 34 | default: |
---|
| 35 | Usage: |
---|
| 36 | cerr << "Usage: " << argv[0] << " [ times (> 0) ]" << endl; |
---|
| 37 | exit( EXIT_FAILURE ); |
---|
| 38 | } // switch |
---|
| 39 | |
---|
| 40 | uActor::start(); // start actor system |
---|
| 41 | starttime = steady_clock::now(); |
---|
| 42 | Send send; |
---|
| 43 | send | msg; |
---|
| 44 | uActor::stop(); // wait for all actors to terminate |
---|
| 45 | } // main |
---|
| 46 | |
---|
| 47 | // /usr/bin/time -f "%Uu %Ss %Er %Mkb" a.out |
---|
| 48 | |
---|
| 49 | // Local Variables: // |
---|
| 50 | // compile-command: "u++-work -g -Wall -Wextra -O3 -nodebug -DNDEBUG -multi uC++SendStatic.cc" // |
---|
| 51 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.