summaryrefslogtreecommitdiffstats
path: root/contrib/benchmarks/scxmlcc/statesPerSecond.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/benchmarks/scxmlcc/statesPerSecond.cpp')
-rw-r--r--contrib/benchmarks/scxmlcc/statesPerSecond.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/contrib/benchmarks/scxmlcc/statesPerSecond.cpp b/contrib/benchmarks/scxmlcc/statesPerSecond.cpp
new file mode 100644
index 0000000..e0dc7b2
--- /dev/null
+++ b/contrib/benchmarks/scxmlcc/statesPerSecond.cpp
@@ -0,0 +1,47 @@
+#include <iostream>
+#include <chrono>
+#include <stdlib.h>
+
+#include "test.h"
+
+using namespace std;
+using namespace std::chrono;
+
+typedef MACHINE_NAME sc;
+
+long iterations = 0;
+long initMs = 0;
+system_clock::time_point report;
+system_clock::time_point endTime;
+
+template<> void sc::state_actions<sc::state_mark>::enter(sc::data_model &m)
+{
+ iterations++;
+ system_clock::time_point now = system_clock::now();
+
+ if (now > report) {
+ report = now + seconds(1);
+ std::cout << initMs << ", " << iterations << std::endl;
+ iterations = 0;
+ }
+ if (now > endTime) {
+ ::exit(EXIT_SUCCESS);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ system_clock::time_point start = system_clock::now();
+
+ sc sc0;
+ system_clock::time_point now = system_clock::now();
+
+ initMs = duration_cast<milliseconds>(now - start).count();
+
+ start = now;
+ report = start + seconds(1);
+ endTime = start + seconds(10);
+
+ sc0.init();
+ return 0;
+}