summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-06-08 09:52:27 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-06-08 09:52:27 (GMT)
commite9b78b546baf50149d121c96df823d44a709a97c (patch)
tree22fd3f72bf2a43ee78ca5e4fd27e1c130b3e5dc0 /test/src
parentcdc9c7da381aa296dc48c2494adcf9ca941d0851 (diff)
downloaduscxml-e9b78b546baf50149d121c96df823d44a709a97c.zip
uscxml-e9b78b546baf50149d121c96df823d44a709a97c.tar.gz
uscxml-e9b78b546baf50149d121c96df823d44a709a97c.tar.bz2
Performance improvements
Diffstat (limited to 'test/src')
-rw-r--r--test/src/test-gen-c.cpp12
-rw-r--r--test/src/test-performance.cpp46
2 files changed, 52 insertions, 6 deletions
diff --git a/test/src/test-gen-c.cpp b/test/src/test-gen-c.cpp
index b7cee32..0f83da3 100644
--- a/test/src/test-gen-c.cpp
+++ b/test/src/test-gen-c.cpp
@@ -570,11 +570,11 @@ public:
e.invokeid = USER_DATA(ctx)->invokeId;
}
- USER_DATA(ctx)->sendUUIDs[e.uuid] = std::make_tuple(e.sendid, target, type);
+ USER_DATA(ctx)->sendUUIDs[e.getUUID()] = std::make_tuple(e.sendid, target, type);
if (delayMs > 0) {
- USER_DATA(ctx)->delayQueue.enqueueDelayed(e, delayMs, e.uuid);
+ USER_DATA(ctx)->delayQueue.enqueueDelayed(e, delayMs, e.getUUID());
} else {
- USER_DATA(ctx)->eventReady(e, e.uuid);
+ USER_DATA(ctx)->eventReady(e, e.getUUID());
}
return USCXML_ERR_OK;
@@ -840,9 +840,9 @@ public:
//std::make_tuple(e.sendid, target, type);
- std::string sendid = std::get<0>(sendUUIDs[e.uuid]);
- std::string target = std::get<1>(sendUUIDs[e.uuid]);
- std::string type = std::get<2>(sendUUIDs[e.uuid]);
+ std::string sendid = std::get<0>(sendUUIDs[e.getUUID()]);
+ std::string target = std::get<1>(sendUUIDs[e.getUUID()]);
+ std::string type = std::get<2>(sendUUIDs[e.getUUID()]);
if (target == "#_internal") {
e.eventType = Event::INTERNAL;
diff --git a/test/src/test-performance.cpp b/test/src/test-performance.cpp
new file mode 100644
index 0000000..8df740d
--- /dev/null
+++ b/test/src/test-performance.cpp
@@ -0,0 +1,46 @@
+#include "uscxml/config.h"
+#include "uscxml/Interpreter.h"
+#include <sys/time.h>
+
+#include <iostream>
+
+using namespace uscxml;
+using namespace std::chrono;
+
+int main(int argc, char** argv) {
+ if (argc < 2) {
+ std::cout << "Expected filename as first parameter" << std::endl;
+ exit(EXIT_FAILURE);
+ }
+
+ Interpreter interpreter = Interpreter::fromURL(argv[1]);
+
+ InterpreterState state;
+ system_clock::time_point start = system_clock::now();
+
+ while((state = interpreter.step()) != InterpreterState::USCXML_INITIALIZED) {}
+ system_clock::time_point now = system_clock::now();
+
+ std::cout << "init: " << duration_cast<milliseconds>(now - start).count() << "ms" << std::endl;
+
+ start = system_clock::now();
+ system_clock::time_point endTime = start + seconds(10);
+ system_clock::time_point report = start + seconds(1);
+
+ unsigned long iterations = 0;
+
+ while(true) {
+ now = system_clock::now();
+ if (now > endTime)
+ break;
+
+ interpreter.step();
+
+ iterations++;
+ if (now > report) {
+ report = now + seconds(1);
+ std::cout << "steps / sec: " << iterations << std::endl;
+ iterations = 0;
+ }
+ }
+}