summaryrefslogtreecommitdiffstats
path: root/test/src/test-c-machine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/test-c-machine.cpp')
-rw-r--r--test/src/test-c-machine.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/test/src/test-c-machine.cpp b/test/src/test-c-machine.cpp
index c8848ac..35f06a4 100644
--- a/test/src/test-c-machine.cpp
+++ b/test/src/test-c-machine.cpp
@@ -493,15 +493,15 @@ int exec_content_foreach_done(const scxml_ctx* ctx, const scxml_elem_foreach* fo
int exec_content_log(const scxml_ctx* ctx, const char* label, const char* expr) {
try {
if (label != NULL) {
- printf("%s%s", label, (expr != NULL ? ": " : ""));
- }
- if (expr != NULL) {
- std::string msg = USER_DATA(ctx)->datamodel.evalAsString(expr);
- printf("%s", msg.c_str());
- }
- if (label != NULL || expr != NULL) {
- printf("\n");
- }
+ printf("%s%s", label, (expr != NULL ? ": " : ""));
+ }
+ if (expr != NULL) {
+ std::string msg = USER_DATA(ctx)->datamodel.evalAsString(expr);
+ printf("%s", msg.c_str());
+ }
+ if (label != NULL || expr != NULL) {
+ printf("\n");
+ }
} catch (Event e) {
exec_content_raise(ctx, e.name.c_str());
return SCXML_ERR_EXEC_CONTENT;
@@ -546,6 +546,10 @@ void* dequeue_internal(const scxml_ctx* ctx) {
int main(int argc, char** argv) {
+ std::cout << "sizeof(scxml_state): " << sizeof(scxml_state) << std::endl;
+ std::cout << "sizeof(scxml_transition): " << sizeof(scxml_transition) << std::endl;
+ std::cout << "sizeof(scxml_ctx): " << sizeof(scxml_ctx) << std::endl;
+
#ifdef APPLE
mach_timebase_info_data_t timebase_info;
mach_timebase_info(&timebase_info);
@@ -574,7 +578,7 @@ int main(int argc, char** argv) {
const char* envBenchmarkRuns = getenv("USCXML_BENCHMARK_ITERATIONS");
if (envBenchmarkRuns != NULL) {
benchmarkRuns = strTo<size_t>(envBenchmarkRuns);
- }
+ }
size_t remainingRuns = benchmarkRuns;
@@ -594,8 +598,8 @@ int main(int argc, char** argv) {
double avgDm = 0;
#endif
- Timer tTotal;
- tTotal.start();
+ Timer tTotal;
+ tTotal.start();
while(remainingRuns-- > 0) {
memset(&ctx, 0, sizeof(scxml_ctx));
@@ -628,14 +632,14 @@ int main(int argc, char** argv) {
microSteps = 0;
while((err = scxml_step(&ctx)) == SCXML_ERR_OK) {
- t.stop();
- microSteps++;
- if (ctx.event != NULL) {
- delete ((Event*)(ctx.event));
- }
- t.start();
+ t.stop();
+ microSteps++;
+ if (ctx.event != NULL) {
+ delete ((Event*)(ctx.event));
+ }
+ t.start();
}
- microSteps++;
+ microSteps++;
assert(ctx.flags & SCXML_CTX_TOP_LEVEL_FINAL);
@@ -653,17 +657,20 @@ int main(int argc, char** argv) {
}
}
- assert(IS_SET(passIdx, ctx.config));
+ if(!IS_SET(passIdx, ctx.config)) {
+ std::cerr << "Interpreter did not end in pass" << std::endl;
+ exit(EXIT_FAILURE);
+ }
interpreterInfo.delayQueue.cancelAllEvents();
interpreterInfo.eq.clear();
interpreterInfo.iq.clear();
}
- tTotal.stop();
- std::cout << benchmarkRuns << " iterations" << std::endl;
- std::cout << tTotal.elapsed * 1000.0 << " ms in total" << std::endl;
+ tTotal.stop();
+ std::cout << benchmarkRuns << " iterations" << std::endl;
+ std::cout << tTotal.elapsed * 1000.0 << " ms in total" << std::endl;
std::cout << (avg * 1000.0) / (double)benchmarkRuns << " ms per execution" << std::endl;
- std::cout << microSteps << " microsteps per iteration" << std::endl;
- std::cout << (avg * 1000.0) / ((double)benchmarkRuns * (double)microSteps) << " ms per microstep" << std::endl;
+ std::cout << microSteps << " microsteps per iteration" << std::endl;
+ std::cout << (avg * 1000.0) / ((double)benchmarkRuns * (double)microSteps) << " ms per microstep" << std::endl;
#ifdef BUILD_PROFILING
std::cout << (avgDm * 1000.0) / (double)benchmarkRuns << " ms in datamodel" << std::endl;
std::cout << ((avg - avgDm) * 1000.0) / ((double)benchmarkRuns * (double)microSteps) << " ms per microstep \\wo datamodel" << std::endl;