source: doc/theses/colby_parsons_MMAth/benchmarks/actors/caf/CAFSendStatic.cpp @ 625f3e2

ADTast-experimental
Last change on this file since 625f3e2 was b86d14c, checked in by caparson <caparson@…>, 16 months ago

added caf benchmarks

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#include <iostream>
2using namespace std;
3#include <chrono>
4using namespace chrono;
5
6#include "caf/actor_ostream.hpp"
7#include "caf/caf_main.hpp"
8#include "caf/event_based_actor.hpp"
9using namespace caf;
10
11int Times = 5'000'000;                                                                  // default values
12time_point<steady_clock> starttime;
13
14class Send : public event_based_actor {
15  public:
16        Send( caf::actor_config & cfg ) : event_based_actor( cfg ) {}
17
18        behavior make_behavior() override {
19                return {
20                        [=]( int & cnt ) -> void {
21                                if ( cnt >= Times ) {
22                                        aout(this) << (steady_clock::now() - starttime).count() / Times << endl;
23                                        this->quit();
24                                        return;
25                                } // if
26                                //aout(this) << cnt << endl;
27                                this->send( this, cnt + 1 );
28                        }
29                };
30        }
31}; // Send
32
33void caf_main( actor_system & sys ) {
34        auto starter = sys.spawn<Send>();
35        starttime = steady_clock::now();
36        caf::anon_send( starter, 0 );
37} // caf_main
38
39int main( int argc, char * argv[] ) {
40        switch ( argc ) {
41          case 2:
42                if ( strcmp( argv[1], "d" ) != 0 ) { Times = stoi( argv[1] ); }
43                if ( Times < 1 ) goto Usage;
44          case 1:                                                                                       // use defaults
45                break;
46          default:
47          Usage:
48                cerr << "Usage: " << argv[0] << " [ times (> 0) ]" << endl;
49                exit( EXIT_FAILURE );
50        } // switch
51
52        caf::exec_main_init_meta_objects<>();
53        caf::core::init_global_meta_objects();
54        return caf::exec_main<>(caf_main, argc, argv);
55} // main
56//CAF_MAIN()
57
58// /usr/bin/time -f "%Uu %Ss %Er %Mkb" a.out
59
60// Local Variables: //
61// compile-command: "g++-10 -O3 -Wall -std=c++17 -ICAF/actor-framework/libcaf_core -ICAF/actor-framework/libcaf_core/caf -ICAF/actor-framework/build/libcaf_core -LCAF/actor-framework/build/libcaf_core -LCAF/actor-framework/build/libcaf_io CAFSendStatic.cpp -lcaf_io -lcaf_core -Wl,-rpath=CAF/actor-framework/build/libcaf_core" //
62// End: //
Note: See TracBrowser for help on using the repository browser.