#include #include #include #include "everything_else.hpp" #include "perftools.hpp" #include "signal_handler.hpp" #include "sim_loop.hpp" #include "mempool.hpp" #include "model.hpp" using namespace std; int main(int argc, char **argv) { // init sim env const uint64_t eventsPerChunk = 100000; uint64_t totalEventsProcessed(0); installSigIntHandler(); assertSimDir(); // parse command line args assert(argc == 2); Time until(atof(argv[1])); { SimLoop sim; Time startTime(sim.currentTime()), oldTime(startTime); cout << "simulating from " << oldTime() << " to " << until() << endl; // run for requested time Timer timerAll; while (oldTime < until && !terminationRequested) { uint64_t eventsProcessed = eventsPerChunk - sim.run(until, eventsPerChunk); totalEventsProcessed += eventsProcessed; Time newTime(sim.currentTime()), dt(newTime - oldTime); cout << "\r\033[K" << newTime() << "\t" << eventsProcessed / dt() << " Hz(v)\t" << totalEventsProcessed / timerAll.diff() << " Hz(p)\t" << totalEventsProcessed << " events\t"; if (newTime < until) cout << "ETA " << ceil( (until() - newTime()) / (newTime() - startTime()) * timerAll.diff()); cout << flush; oldTime = newTime; } if (terminationRequested) { cout << " ... received SIGINT, terminating" << endl; }else{ cout << "\r\033[K"; } // print summary cout << "simulated " << totalEventsProcessed << " events " << "in " << timerAll.diff() << " s " << "(" << totalEventsProcessed / timerAll.diff() << " Hz(p))" << endl; // sync to disk cout << "syncing ... " << flush; Timer timerSync; sim.sync(); cout << "done (" << timerSync.diff() << "s)" << endl; if (terminationRequested) sigIntExit(); } return 0; }