summaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorStefan Radomski <sradomski@mintwerk.de>2016-01-17 21:27:21 (GMT)
committerStefan Radomski <sradomski@mintwerk.de>2016-01-17 21:27:21 (GMT)
commit575c2711df910f0b8ecce277bf7333077e235855 (patch)
treefda5fa874caf8b7ffb334cb8b861cf5c0dd625d8 /test/src
parentf9cb8905b37c8fd38e1e4b79114fd0c194c8c3c7 (diff)
downloaduscxml-575c2711df910f0b8ecce277bf7333077e235855.zip
uscxml-575c2711df910f0b8ecce277bf7333077e235855.tar.gz
uscxml-575c2711df910f0b8ecce277bf7333077e235855.tar.bz2
Beautified generated C code from transformation
Diffstat (limited to 'test/src')
-rw-r--r--test/src/test-c-machine.cpp57
-rw-r--r--test/src/test-c-machine.machine.c395
-rw-r--r--test/src/test-lifecycle.cpp38
-rw-r--r--test/src/test-w3c.cpp142
4 files changed, 343 insertions, 289 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;
diff --git a/test/src/test-c-machine.machine.c b/test/src/test-c-machine.machine.c
index efc4c22..e9616dc 100644
--- a/test/src/test-c-machine.machine.c
+++ b/test/src/test-c-machine.machine.c
@@ -25,8 +25,8 @@
#define SCXML_ERR_UNSUPPORTED 8
#define SCXML_MACHINE_NAME ""
-#define SCXML_NUMBER_STATES 11
-#define SCXML_NUMBER_TRANSITIONS 13
+#define SCXML_NUMBER_STATES 5
+#define SCXML_NUMBER_TRANSITIONS 4
#define SCXML_TRANS_SPONTANEOUS 0x01
#define SCXML_TRANS_TARGETLESS 0x02
@@ -93,26 +93,26 @@ struct scxml_elem_data {
struct scxml_state {
const char* name; // eventual name
- uint16_t parent; // parent
- exec_content_t on_entry; // on entry handlers
- exec_content_t on_exit; // on exit handlers
- invoke_t invoke; // invocations
- char children[2]; // all children
- char completion[2]; // default completion
- char ancestors[2]; // all ancestors
+ const uint8_t parent; // parent
+ const exec_content_t on_entry; // on entry handlers
+ const exec_content_t on_exit; // on exit handlers
+ const invoke_t invoke; // invocations
+ const char children[1]; // all children
+ const char completion[1]; // default completion
+ const char ancestors[1]; // all ancestors
const scxml_elem_data* data;
- uint8_t type; // atomic, parallel, compound, final, history
+ const uint8_t type; // atomic, parallel, compound, final, history
};
struct scxml_transition {
- uint16_t source;
- char target[2];
+ const uint8_t source;
+ const char target[1];
const char* event;
const char* condition;
- exec_content_t on_transition;
- uint8_t type;
- char conflicts[2];
- char exit_set[2];
+ const exec_content_t on_transition;
+ const uint8_t type;
+ const char conflicts[1];
+ const char exit_set[1];
};
struct scxml_elem_foreach {
@@ -128,7 +128,7 @@ struct scxml_elem_param {
};
struct scxml_elem_donedata {
- uint16_t source;
+ const uint8_t source;
const char* content;
const char* contentexpr;
const scxml_elem_param* params;
@@ -142,12 +142,11 @@ struct scxml_elem_invoke {
const char* id;
const char* idlocation;
const char* namelist;
- uint8_t autoforward;
+ const uint8_t autoforward;
const scxml_elem_param* params;
const exec_content_finalize_t* finalize;
const char* content;
const char* contentexpr;
- void* user_data;
};
struct scxml_elem_send {
@@ -165,16 +164,15 @@ struct scxml_elem_send {
const char* content;
const char* contentexpr;
const scxml_elem_param* params;
- void* user_data;
};
struct scxml_ctx {
uint8_t flags;
- char config[2];
- char history[2];
- char pending_invokes[2];
- char initialized_data[2];
+ char config[1];
+ char history[1];
+ char pending_invokes[1];
+ char initialized_data[1];
void* user_data;
void* event;
@@ -198,91 +196,64 @@ struct scxml_ctx {
invoke_t invoke;
};
-static scxml_elem_data scxml_elem_datas[2] = {
- { "Var1", NULL, "0", NULL },
+static const scxml_elem_data scxml_elem_datas[3] = {
+ /* id, src, expr, content */
+ { "Var1", NULL, "1", NULL },
+ { "Var2", NULL, NULL, NULL },
{ NULL, NULL, NULL, NULL }
};
-static scxml_elem_send scxml_elem_sends[1] = {
- { "timeout", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "'1s'", NULL, NULL, NULL, NULL, NULL }
+static const scxml_elem_param scxml_elem_params[2] = {
+ /* name, expr, location */
+ { "aParam", "Var1", NULL },
+ { NULL, NULL, NULL }
+};
+
+static const scxml_elem_send scxml_elem_sends[1] = {
+ {
+ /* event */ "event1",
+ /* eventexpr */ NULL,
+ /* target */ NULL,
+ /* targetexpr */ NULL,
+ /* type */ NULL,
+ /* typeexpr */ NULL,
+ /* id */ NULL,
+ /* idlocation */ NULL,
+ /* delay */ NULL,
+ /* delayexpr */ NULL,
+ /* namelist */ NULL,
+ /* content */ NULL,
+ /* contentexpr */ NULL,
+ /* params */ &scxml_elem_params[0]
+ }
};
-static scxml_elem_donedata scxml_elem_donedatas[1] = {
- { 0, NULL, NULL }
+static const scxml_elem_donedata scxml_elem_donedatas[1] = {
+ /* source, content, contentexpr, params */
+ { 0, NULL, NULL, NULL }
};
static int global_script(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
return SCXML_ERR_OK;
}
-static int s0_on_exit_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
+static int s0_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
int err = SCXML_ERR_OK;
if likely(ctx->exec_content_assign != NULL) {
- if ((ctx->exec_content_assign(ctx, "Var1", "Var1 + 1")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- if likely(ctx->exec_content_log != NULL) {
- if unlikely((ctx->exec_content_log(ctx, "Var1 is", "Var1")) != SCXML_ERR_OK) return err;
+ if ((ctx->exec_content_assign(ctx, "Var1", "2")) != SCXML_ERR_OK) return err;
} else {
return SCXML_ERR_MISSING_CALLBACK;
}
- return SCXML_ERR_OK;
-}
-
-static int s0_on_exit(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- s0_on_exit_0(ctx, state, event);
- return SCXML_ERR_OK;
-}
-
-static int s0_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
if likely(ctx->exec_content_send != NULL) {
if ((ctx->exec_content_send(ctx, &scxml_elem_sends[0])) != SCXML_ERR_OK) return err;
} else {
return SCXML_ERR_MISSING_CALLBACK;
}
- if likely(ctx->exec_content_raise != NULL) {
- if unlikely((ctx->exec_content_raise(ctx, "event1")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static int s0_initial(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_raise != NULL) {
- if unlikely((ctx->exec_content_raise(ctx, "event2")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- if likely(ctx->exec_content_log != NULL) {
- if unlikely((ctx->exec_content_log(ctx, "initial transition in s0", NULL)) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
return SCXML_ERR_OK;
}
static int s0_on_entry(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
s0_on_entry_0(ctx, state, event);
- s0_initial(ctx, state, event);
- return SCXML_ERR_OK;
-}
-
-static int s03_on_entry_0(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_log != NULL) {
- if unlikely((ctx->exec_content_log(ctx, "Var1 when entering s03", "Var1")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- return SCXML_ERR_OK;
-}
-
-static int s03_on_entry(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
- s03_on_entry_0(ctx, state, event);
return SCXML_ERR_OK;
}
@@ -316,55 +287,130 @@ static int fail_on_entry(const scxml_ctx* ctx, const scxml_state* state, const v
return SCXML_ERR_OK;
}
-static int sh1_transition0_on_trans(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
+static int s0_transition0_on_trans(const scxml_ctx* ctx, const scxml_state* state, const void* event) {
int err = SCXML_ERR_OK;
- if likely(ctx->exec_content_raise != NULL) {
- if unlikely((ctx->exec_content_raise(ctx, "event3")) != SCXML_ERR_OK) return err;
- } else {
- return SCXML_ERR_MISSING_CALLBACK;
- }
- if likely(ctx->exec_content_log != NULL) {
- if unlikely((ctx->exec_content_log(ctx, "history transition in sh1", NULL)) != SCXML_ERR_OK) return err;
+ if likely(ctx->exec_content_assign != NULL) {
+ if ((ctx->exec_content_assign(ctx, "Var2", "_event.data.aParam")) != SCXML_ERR_OK) return err;
} else {
return SCXML_ERR_MISSING_CALLBACK;
}
return SCXML_ERR_OK;
}
-static scxml_state scxml_states[11] = {
- { NULL, 0, NULL, NULL, NULL, { 0x82, 0x07 /* 01000001111, 1 7 8 9 10 */ }, { 0x02, 0x00 /* 01000000000, 1 */ }, { 0x00, 0x00 /* 00000000000, */ }, (const scxml_elem_data*)&scxml_elem_datas[0], SCXML_STATE_COMPOUND },
- { "s0", 0, s0_on_entry, s0_on_exit, NULL, { 0x7c, 0x00 /* 00111110000, 2 3 4 5 6 */ }, { 0x04, 0x00 /* 00100000000, 2 */ }, { 0x01, 0x00 /* 10000000000, 0 */ }, NULL, SCXML_STATE_COMPOUND },
- { NULL, 1, NULL, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x03, 0x00 /* 11000000000, 0 1 */ }, NULL, SCXML_STATE_INITIAL },
- { "sh1", 1, NULL, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x74, 0x00 /* 00101110000, 2 4 5 6 */ }, { 0x03, 0x00 /* 11000000000, 0 1 */ }, NULL, SCXML_STATE_HISTORY_SHALLOW },
- { "s01", 1, NULL, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x03, 0x00 /* 11000000000, 0 1 */ }, NULL, SCXML_STATE_ATOMIC },
- { "s02", 1, NULL, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x03, 0x00 /* 11000000000, 0 1 */ }, NULL, SCXML_STATE_ATOMIC },
- { "s03", 1, s03_on_entry, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x03, 0x00 /* 11000000000, 0 1 */ }, NULL, SCXML_STATE_ATOMIC },
- { "s2", 0, NULL, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x01, 0x00 /* 10000000000, 0 */ }, NULL, SCXML_STATE_ATOMIC },
- { "s3", 0, NULL, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x01, 0x00 /* 10000000000, 0 */ }, NULL, SCXML_STATE_ATOMIC },
- { "pass", 0, pass_on_entry, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x01, 0x00 /* 10000000000, 0 */ }, NULL, SCXML_STATE_FINAL },
- { "fail", 0, fail_on_entry, NULL, NULL, { 0x00, 0x00 /* 00000000000, */ }, { 0x00, 0x00 /* 00000000000, */ }, { 0x01, 0x00 /* 10000000000, 0 */ }, NULL, SCXML_STATE_FINAL }
+static const scxml_state scxml_states[5] = {
+ { /* state number 0 */
+ /* name */ NULL,
+ /* parent */ 0,
+ /* onentry */ NULL,
+ /* onexit */ NULL,
+ /* invoke */ NULL,
+ /* children */ { 0x1e /* 01111, 1 2 3 4 */ },
+ /* completion */ { 0x02 /* 01000, 1 */ },
+ /* ancestors */ { 0x00 /* 00000, */ },
+ /* data */ &scxml_elem_datas[0],
+ /* type */ SCXML_STATE_COMPOUND,
+ },
+ { /* state number 1 */
+ /* name */ "s0",
+ /* parent */ 0,
+ /* onentry */ s0_on_entry,
+ /* onexit */ NULL,
+ /* invoke */ NULL,
+ /* children */ { 0x00 /* 00000, */ },
+ /* completion */ { 0x00 /* 00000, */ },
+ /* ancestors */ { 0x01 /* 10000, 0 */ },
+ /* data */ NULL,
+ /* type */ SCXML_STATE_ATOMIC,
+ },
+ { /* state number 2 */
+ /* name */ "s1",
+ /* parent */ 0,
+ /* onentry */ NULL,
+ /* onexit */ NULL,
+ /* invoke */ NULL,
+ /* children */ { 0x00 /* 00000, */ },
+ /* completion */ { 0x00 /* 00000, */ },
+ /* ancestors */ { 0x01 /* 10000, 0 */ },
+ /* data */ NULL,
+ /* type */ SCXML_STATE_ATOMIC,
+ },
+ { /* state number 3 */
+ /* name */ "pass",
+ /* parent */ 0,
+ /* onentry */ pass_on_entry,
+ /* onexit */ NULL,
+ /* invoke */ NULL,
+ /* children */ { 0x00 /* 00000, */ },
+ /* completion */ { 0x00 /* 00000, */ },
+ /* ancestors */ { 0x01 /* 10000, 0 */ },
+ /* data */ NULL,
+ /* type */ SCXML_STATE_FINAL,
+ },
+ { /* state number 4 */
+ /* name */ "fail",
+ /* parent */ 0,
+ /* onentry */ fail_on_entry,
+ /* onexit */ NULL,
+ /* invoke */ NULL,
+ /* children */ { 0x00 /* 00000, */ },
+ /* completion */ { 0x00 /* 00000, */ },
+ /* ancestors */ { 0x01 /* 10000, 0 */ },
+ /* data */ NULL,
+ /* type */ SCXML_STATE_FINAL,
+ }
+};
+
+static const uint8_t scxml_transitions_doc_order[4] = {
+ 0, 1, 2, 3
};
-static scxml_transition scxml_transitions[13] = {
- { 2, { 0x08, 0x00 /* 00010000000 */ }, NULL, NULL, NULL, SCXML_TRANS_SPONTANEOUS | SCXML_TRANS_INITIAL, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 3, { 0x10, 0x00 /* 00001000000 */ }, NULL, NULL, sh1_transition0_on_trans, SCXML_TRANS_SPONTANEOUS | SCXML_TRANS_HISTORY, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 4, { 0x20, 0x00 /* 00000100000 */ }, "event1", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0x7c, 0x00 /* 00111110000 */ } },
- { 4, { 0x00, 0x04 /* 00000000001 */ }, "*", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 5, { 0x40, 0x00 /* 00000010000 */ }, "event2", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0x7c, 0x00 /* 00111110000 */ } },
- { 5, { 0x00, 0x04 /* 00000000001 */ }, "*", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 6, { 0x02, 0x00 /* 01000000000 */ }, "event3", "Var1==0", NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 6, { 0x80, 0x00 /* 00000001000 */ }, "event1", "Var1==1", NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 6, { 0x00, 0x04 /* 00000000001 */ }, "*", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 7, { 0x00, 0x01 /* 00000000100 */ }, "event2", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 7, { 0x00, 0x04 /* 00000000001 */ }, "*", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 8, { 0x00, 0x04 /* 00000000001 */ }, "event3", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } },
- { 8, { 0x00, 0x02 /* 00000000010 */ }, "timeout", NULL, NULL, 0, { 0xff, 0x1f /* 1111111111111 */ }, { 0xfe, 0x07 /* 01111111111 */ } }
+static const scxml_transition scxml_transitions[4] = {
+ { /* transition number 0 with priority 0 */
+ /* name */ 1,
+ /* target */ { 0x04 /* 00100, 2 */ },
+ /* event */ "event1",
+ /* condition */ NULL,
+ /* ontrans */ s0_transition0_on_trans,
+ /* type */ 0,
+ /* conflicts */ { 0x0f /* 1111, 0 1 2 3 */ },
+ /* exit set */ { 0x1e /* 01111, 1 2 3 4 */ }
+ },
+ { /* transition number 1 with priority 1 */
+ /* name */ 1,
+ /* target */ { 0x10 /* 00001, 4 */ },
+ /* event */ "*",
+ /* condition */ NULL,
+ /* ontrans */ NULL,
+ /* type */ 0,
+ /* conflicts */ { 0x0f /* 1111, 0 1 2 3 */ },
+ /* exit set */ { 0x1e /* 01111, 1 2 3 4 */ }
+ },
+ { /* transition number 2 with priority 2 */
+ /* name */ 2,
+ /* target */ { 0x08 /* 00010, 3 */ },
+ /* event */ NULL,
+ /* condition */ "Var2==2",
+ /* ontrans */ NULL,
+ /* type */ SCXML_TRANS_SPONTANEOUS,
+ /* conflicts */ { 0x0f /* 1111, 0 1 2 3 */ },
+ /* exit set */ { 0x1e /* 01111, 1 2 3 4 */ }
+ },
+ { /* transition number 3 with priority 3 */
+ /* name */ 2,
+ /* target */ { 0x10 /* 00001, 4 */ },
+ /* event */ NULL,
+ /* condition */ NULL,
+ /* ontrans */ NULL,
+ /* type */ SCXML_TRANS_SPONTANEOUS,
+ /* conflicts */ { 0x0f /* 1111, 0 1 2 3 */ },
+ /* exit set */ { 0x1e /* 01111, 1 2 3 4 */ }
+ }
};
#ifdef SCXML_VERBOSE
static void printStateNames(const char* a) {
const char* seperator = "";
- for (int i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
if (IS_SET(i, a)) {
printf("%s%s", seperator, (scxml_states[i].name != NULL ? scxml_states[i].name : "UNK"));
seperator = ", ";
@@ -375,9 +421,9 @@ static void printStateNames(const char* a) {
static void printBitsetIndices(const char* a, size_t length) {
const char* seperator = "";
- for (int i = 0; i < length; i++) {
+ for (size_t i = 0; i < length; i++) {
if (IS_SET(i, a)) {
- printf("%s%d", seperator, i);
+ printf("%s%lu", seperator, i);
seperator = ", ";
}
}
@@ -439,15 +485,15 @@ MACRO_STEP:
return SCXML_ERR_DONE;
int err = SCXML_ERR_OK;
- char conflicts[2] = {0, 0};
- char target_set[2] = {0, 0};
- char exit_set[2] = {0, 0};
- char trans_set[2] = {0, 0};
- char entry_set[2] = {0, 0};
+ char conflicts[1] = {0};
+ char target_set[1] = {0};
+ char exit_set[1] = {0};
+ char trans_set[1] = {0};
+ char entry_set[1] = {0};
if unlikely(ctx->flags == SCXML_CTX_PRISTINE) {
global_script(ctx, &scxml_states[0], NULL);
- bit_or(target_set, scxml_states[0].completion, 2);
+ bit_or(target_set, scxml_states[0].completion, 1);
ctx->flags |= SCXML_CTX_SPONTANEOUS | SCXML_CTX_INITIALIZED;
goto ESTABLISH_ENTRY_SET;
}
@@ -464,7 +510,7 @@ MACRO_STEP:
}
SELECT_TRANSITIONS:
- for (int i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
+ for (size_t i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
// never select history or initial transitions automatically
if unlikely(scxml_transitions[i].type & (SCXML_TRANS_HISTORY | SCXML_TRANS_INITIAL))
continue;
@@ -479,20 +525,20 @@ SELECT_TRANSITIONS:
ctx->flags |= SCXML_CTX_TRANSITION_FOUND;
// transitions that are pre-empted
- bit_or(conflicts, scxml_transitions[i].conflicts, 2);
+ bit_or(conflicts, scxml_transitions[i].conflicts, 1);
// states that are directly targeted (resolve as entry-set later)
- bit_or(target_set, scxml_transitions[i].target, 2);
+ bit_or(target_set, scxml_transitions[i].target, 1);
// states that will be left
- bit_or(exit_set, scxml_transitions[i].exit_set, 2);
+ bit_or(exit_set, scxml_transitions[i].exit_set, 1);
SET_BIT(i, trans_set);
}
}
}
}
- bit_and(exit_set, ctx->config, 2);
+ bit_and(exit_set, ctx->config, 1);
if (ctx->flags & SCXML_CTX_TRANSITION_FOUND) {
ctx->flags |= SCXML_CTX_SPONTANEOUS;
@@ -515,77 +561,72 @@ SELECT_TRANSITIONS:
printStateNames(ctx->history);
#endif
-
- // REMEMBER_HISTORY:
- for (int i = 0; i < SCXML_NUMBER_STATES; i++) {
+// REMEMBER_HISTORY:
+ for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
if unlikely(scxml_states[i].type == SCXML_STATE_HISTORY_SHALLOW || scxml_states[i].type == SCXML_STATE_HISTORY_DEEP) {
// a history state whose parent is about to be exited
if unlikely(IS_SET(scxml_states[i].parent, exit_set)) {
- char history[2] = {0, 0};
- bit_copy(history, scxml_states[i].completion, 2);
-
+ char history[1] = {0};
+ bit_copy(history, scxml_states[i].completion, 1);
+
// set those states who were enabled
- bit_and(history, ctx->config, 2);
-
+ bit_and(history, ctx->config, 1);
+
// clear current history with completion mask - TODO: errornously clears nested history
- bit_and_not(ctx->history, scxml_states[i].completion, 2);
-
+ bit_and_not(ctx->history, scxml_states[i].completion, 1);
+
// set history
- bit_or(ctx->history, history, 2);
+ bit_or(ctx->history, history, 1);
}
}
}
-#ifdef SCXML_VERBOSE
- printf("Transitions: ");
- printBitsetIndices(trans_set, sizeof(char) * 8 * 2);
-#endif
ESTABLISH_ENTRY_SET:
// calculate new entry set
- bit_copy(entry_set, target_set, 2);
+ bit_copy(entry_set, target_set, 1);
// iterate for ancestors
- for (int i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
if (IS_SET(i, entry_set)) {
- bit_or(entry_set, scxml_states[i].ancestors, 2);
+ bit_or(entry_set, scxml_states[i].ancestors, 1);
}
}
// iterate for descendants
- for (int i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
if (IS_SET(i, entry_set)) {
switch (scxml_states[i].type) {
case SCXML_STATE_PARALLEL: {
- bit_or(entry_set, scxml_states[i].completion, 2);
+ bit_or(entry_set, scxml_states[i].completion, 1);
break;
}
case SCXML_STATE_HISTORY_SHALLOW:
case SCXML_STATE_HISTORY_DEEP: {
- char history_targets[2] = {0, 0};
- if (!bit_has_and(scxml_states[i].completion, ctx->history, 2) &&
+ char history_targets[1] = {0};
+ if (!bit_has_and(scxml_states[i].completion, ctx->history, 1) &&
!IS_SET(scxml_states[i].parent, ctx->config)) {
// nothing set for history, look for a default transition or enter parents completion
- for (int j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
+ for (size_t j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
if unlikely(scxml_transitions[j].source == i) {
- bit_or(entry_set, scxml_transitions[j].target, 2);
+ bit_or(entry_set, scxml_transitions[j].target, 1);
SET_BIT(j, trans_set);
break;
}
}
// TODO: enter parents default completion here
} else {
- bit_copy(history_targets, scxml_states[i].completion, 2);
- bit_and(history_targets, ctx->history, 2);
- bit_or(entry_set, history_targets, 2);
+ bit_copy(history_targets, scxml_states[i].completion, 1);
+ bit_and(history_targets, ctx->history, 1);
+ bit_or(entry_set, history_targets, 1);
}
break;
}
case SCXML_STATE_INITIAL: {
- for (int j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
+ for (size_t j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
if (scxml_transitions[j].source == i) {
SET_BIT(j, trans_set);
CLEARBIT(i, entry_set);
- bit_or(entry_set, scxml_transitions[j].target, 2);
+ bit_or(entry_set, scxml_transitions[j].target, 1);
// one target may have been above, reestablish completion
// goto ADD_DESCENDANTS; // initial will have to be first!
}
@@ -593,11 +634,11 @@ ESTABLISH_ENTRY_SET:
break;
}
case SCXML_STATE_COMPOUND: { // we need to check whether one child is already in entry_set
- if (!bit_has_and(entry_set, scxml_states[i].children, 2) &&
- (!bit_has_and(ctx->config, scxml_states[i].children, 2) ||
- bit_has_and(exit_set, scxml_states[i].children, 2)))
+ if (!bit_has_and(entry_set, scxml_states[i].children, 1) &&
+ (!bit_has_and(ctx->config, scxml_states[i].children, 1) ||
+ bit_has_and(exit_set, scxml_states[i].children, 1)))
{
- bit_or(entry_set, scxml_states[i].completion, 2);
+ bit_or(entry_set, scxml_states[i].completion, 1);
}
break;
}
@@ -605,8 +646,14 @@ ESTABLISH_ENTRY_SET:
}
}
+#ifdef SCXML_VERBOSE
+ printf("Transitions: ");
+ printBitsetIndices(trans_set, sizeof(char) * 8 * 1);
+#endif
+
// EXIT_STATES:
- for (int i = SCXML_NUMBER_STATES - 1; i >= 0; i--) {
+ size_t i = SCXML_NUMBER_STATES;
+ while(i-- > 0) {
if (IS_SET(i, exit_set) && IS_SET(i, ctx->config)) {
// call all on exit handlers
if (scxml_states[i].on_exit != NULL) {
@@ -618,7 +665,7 @@ ESTABLISH_ENTRY_SET:
}
// TAKE_TRANSITIONS:
- for (int i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
+ for (size_t i = 0; i < SCXML_NUMBER_TRANSITIONS; i++) {
if (IS_SET(i, trans_set) && (scxml_transitions[i].type & SCXML_TRANS_HISTORY) == 0) {
// call executable content in transition
if (scxml_transitions[i].on_transition != NULL) {
@@ -636,7 +683,7 @@ ESTABLISH_ENTRY_SET:
#endif
// ENTER_STATES:
- for (int i = 0; i < SCXML_NUMBER_STATES; i++) {
+ for (size_t i = 0; i < SCXML_NUMBER_STATES; i++) {
if (IS_SET(i, entry_set) && !IS_SET(i, ctx->config)) {
// these are no proper states
if unlikely(scxml_states[i].type == SCXML_STATE_HISTORY_DEEP ||
@@ -660,7 +707,7 @@ ESTABLISH_ENTRY_SET:
}
// take history transitions
- for (int j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
+ for (size_t j = 0; j < SCXML_NUMBER_TRANSITIONS; j++) {
if unlikely(IS_SET(j, trans_set) &&
(scxml_transitions[j].type & SCXML_TRANS_HISTORY) &&
scxml_states[scxml_transitions[j].source].parent == i) {
@@ -680,7 +727,7 @@ ESTABLISH_ENTRY_SET:
ctx->flags |= SCXML_CTX_TOP_LEVEL_FINAL;
} else {
// raise done event
- scxml_elem_donedata* donedata = &scxml_elem_donedatas[0];
+ const scxml_elem_donedata* donedata = &scxml_elem_donedatas[0];
while(ELEM_DONEDATA_IS_SET(donedata)) {
if unlikely(donedata->source == i)
break;
@@ -696,20 +743,20 @@ ESTABLISH_ENTRY_SET:
* 3. Iterate all active final states and remove their ancestors
* 4. If a state remains, not all children of a parallel are final
*/
- for (int j = 0; j < SCXML_NUMBER_STATES; j++) {
+ for (size_t j = 0; j < SCXML_NUMBER_STATES; j++) {
if unlikely(scxml_states[j].type == SCXML_STATE_PARALLEL) {
- char parallel_children[2] = {0, 0};
+ char parallel_children[1] = {0};
size_t parallel = j;
- for (int k = 0; k < SCXML_NUMBER_STATES; k++) {
+ for (size_t k = 0; k < SCXML_NUMBER_STATES; k++) {
if unlikely(IS_SET(parallel, scxml_states[k].ancestors) && IS_SET(k, ctx->config)) {
if (scxml_states[k].type == SCXML_STATE_FINAL) {
- bit_and_not(parallel_children, scxml_states[k].ancestors, 2);
+ bit_and_not(parallel_children, scxml_states[k].ancestors, 1);
} else {
SET_BIT(k, parallel_children);
}
}
}
- if unlikely(!bit_any_set(parallel_children, 2)) {
+ if unlikely(!bit_any_set(parallel_children, 1)) {
ctx->raise_done_event(ctx, &scxml_states[parallel], NULL);
}
}
diff --git a/test/src/test-lifecycle.cpp b/test/src/test-lifecycle.cpp
index 7ac40fa..eeaad96 100644
--- a/test/src/test-lifecycle.cpp
+++ b/test/src/test-lifecycle.cpp
@@ -275,9 +275,9 @@ int main(int argc, char** argv) {
Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
- callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
- callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
- callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
+ callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
callBackSeq.push_back(USCXML_AFTERENTERINGSTATE);
callBackSeq.push_back(USCXML_BEFOREMICROSTEP);
@@ -301,10 +301,10 @@ int main(int argc, char** argv) {
callBackSeq.push_back(USCXML_BEFORECOMPLETION);
callBackSeq.push_back(USCXML_AFTERCOMPLETION);
- assert(interpreter.getState() == USCXML_INSTANTIATED);
- assert(interpreter.step() == USCXML_INITIALIZED);
+ assert(interpreter.getState() == USCXML_INSTANTIATED);
+ assert(interpreter.step() == USCXML_INITIALIZED);
+ assert(interpreter.step() == USCXML_MICROSTEPPED);
assert(interpreter.step() == USCXML_MICROSTEPPED);
- assert(interpreter.step() == USCXML_MICROSTEPPED);
assert(interpreter.step() == USCXML_FINISHED);
assert(callBackSeq.empty());
}
@@ -322,8 +322,8 @@ int main(int argc, char** argv) {
Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
- callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
- callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
callBackSeq.push_back(USCXML_AFTERENTERINGSTATE);
@@ -340,13 +340,13 @@ int main(int argc, char** argv) {
callBackSeq.push_back(USCXML_AFTERCOMPLETION);
assert(interpreter.getState() == USCXML_INSTANTIATED);
- assert(interpreter.step() == USCXML_INITIALIZED);
- assert(interpreter.step() == USCXML_MICROSTEPPED);
+ assert(interpreter.step() == USCXML_INITIALIZED);
+ assert(interpreter.step() == USCXML_MICROSTEPPED);
assert(interpreter.step() == USCXML_FINISHED);
interpreter.reset();
- callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
- callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
callBackSeq.push_back(USCXML_AFTERENTERINGSTATE);
@@ -363,8 +363,8 @@ int main(int argc, char** argv) {
callBackSeq.push_back(USCXML_AFTERCOMPLETION);
assert(interpreter.getState() == USCXML_INSTANTIATED);
- assert(interpreter.step() == USCXML_INITIALIZED);
- assert(interpreter.step() == USCXML_MICROSTEPPED);
+ assert(interpreter.step() == USCXML_INITIALIZED);
+ assert(interpreter.step() == USCXML_MICROSTEPPED);
assert(interpreter.step() == USCXML_FINISHED);
}
@@ -387,8 +387,8 @@ int main(int argc, char** argv) {
Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
- callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
- callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_BEFORETAKINGTRANSITION);
+ callBackSeq.push_back(USCXML_AFTERTAKINGTRANSITION);
callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
callBackSeq.push_back(USCXML_BEFOREEXECUTINGCONTENT);
callBackSeq.push_back(USCXML_AFTEREXECUTINGCONTENT);
@@ -417,11 +417,11 @@ int main(int argc, char** argv) {
callBackSeq.push_back(USCXML_BEFORECOMPLETION);
callBackSeq.push_back(USCXML_AFTERCOMPLETION);
- assert(interpreter.getState() == USCXML_INSTANTIATED);
- assert(interpreter.step() == USCXML_INITIALIZED);
+ assert(interpreter.getState() == USCXML_INSTANTIATED);
+ assert(interpreter.step() == USCXML_INITIALIZED);
assert(interpreter.step() == USCXML_IDLE);
assert(interpreter.step(true) == USCXML_MACROSTEPPED);
- assert(interpreter.step() == USCXML_MICROSTEPPED);
+ assert(interpreter.step() == USCXML_MICROSTEPPED);
assert(interpreter.step() == USCXML_FINISHED);
}
}
diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp
index aa2bff5..0ac33a7 100644
--- a/test/src/test-w3c.cpp
+++ b/test/src/test-w3c.cpp
@@ -81,7 +81,7 @@ class W3CStatusMonitor : public uscxml::InterpreterMonitor {
void beforeCompletion(uscxml::Interpreter tmp) {
if (interpreter.getConfiguration().size() == 1 && interpreter.isInState("pass")) {
#ifndef BUILD_PROFILING
- std::cout << "TEST SUCCEEDED" << std::endl;
+ std::cout << "TEST SUCCEEDED" << std::endl;
#endif
retCode = EXIT_SUCCESS;
return;
@@ -89,34 +89,34 @@ class W3CStatusMonitor : public uscxml::InterpreterMonitor {
#ifndef BUILD_PROFILING
std::cout << "TEST FAILED" << std::endl;
#endif
- retCode = EXIT_FAILURE;
- }
+ retCode = EXIT_FAILURE;
+ }
};
int main(int argc, char** argv) {
using namespace uscxml;
#ifdef APPLE
- mach_timebase_info_data_t timebase_info;
- mach_timebase_info(&timebase_info);
-
- const uint64_t NANOS_PER_MSEC = 1000000ULL;
- double clock2abs = ((double)timebase_info.denom / (double)timebase_info.numer) * NANOS_PER_MSEC;
-
- thread_time_constraint_policy_data_t policy;
- policy.period = 0;
- policy.computation = (uint32_t)(5 * clock2abs); // 5 ms of work
- policy.constraint = (uint32_t)(10 * clock2abs);
- policy.preemptible = FALSE;
-
- int kr = thread_policy_set(pthread_mach_thread_np(pthread_self()),
- THREAD_TIME_CONSTRAINT_POLICY,
- (thread_policy_t)&policy,
- THREAD_TIME_CONSTRAINT_POLICY_COUNT);
- if (kr != KERN_SUCCESS) {
- mach_error("thread_policy_set:", kr);
- exit(1);
- }
+ mach_timebase_info_data_t timebase_info;
+ mach_timebase_info(&timebase_info);
+
+ const uint64_t NANOS_PER_MSEC = 1000000ULL;
+ double clock2abs = ((double)timebase_info.denom / (double)timebase_info.numer) * NANOS_PER_MSEC;
+
+ thread_time_constraint_policy_data_t policy;
+ policy.period = 0;
+ policy.computation = (uint32_t)(5 * clock2abs); // 5 ms of work
+ policy.constraint = (uint32_t)(10 * clock2abs);
+ policy.preemptible = FALSE;
+
+ int kr = thread_policy_set(pthread_mach_thread_np(pthread_self()),
+ THREAD_TIME_CONSTRAINT_POLICY,
+ (thread_policy_t)&policy,
+ THREAD_TIME_CONSTRAINT_POLICY_COUNT);
+ if (kr != KERN_SUCCESS) {
+ mach_error("thread_policy_set:", kr);
+ exit(1);
+ }
#endif
try {
@@ -138,13 +138,13 @@ int main(int argc, char** argv) {
delayFactor = strTo<double>(dfEnv);
}
- const char* envBenchmarkRuns = getenv("USCXML_BENCHMARK_ITERATIONS");
- if (envBenchmarkRuns != NULL) {
- benchmarkRuns = strTo<size_t>(envBenchmarkRuns);
- google::SetStderrLogging(3);
- } else {
- google::LogToStderr();
- }
+ const char* envBenchmarkRuns = getenv("USCXML_BENCHMARK_ITERATIONS");
+ if (envBenchmarkRuns != NULL) {
+ benchmarkRuns = strTo<size_t>(envBenchmarkRuns);
+ google::SetStderrLogging(3);
+ } else {
+ google::LogToStderr();
+ }
int option;
while ((option = getopt(argc, argv, "fd:b:")) != -1) {
@@ -209,58 +209,58 @@ int main(int argc, char** argv) {
W3CStatusMonitor* vm = new W3CStatusMonitor();
interpreter.addMonitor(vm);
- LOG(INFO) << "Benchmarking " << documentURI << (withFlattening ? " FSM converted" : "") << (delayFactor ? "" : " with delays *= " + toStr(delayFactor));
+ LOG(INFO) << "Benchmarking " << documentURI << (withFlattening ? " FSM converted" : "") << (delayFactor ? "" : " with delays *= " + toStr(delayFactor));
- size_t remainingRuns = benchmarkRuns;
- size_t microSteps = 0;
+ size_t remainingRuns = benchmarkRuns;
+ size_t microSteps = 0;
- Timer tTotal;
- tTotal.start();
+ Timer tTotal;
+ tTotal.start();
- double avg = 0;
+ double avg = 0;
#ifdef BUILD_PROFILING
- double avgDm = 0;
- double avgStep = 0;
+ double avgDm = 0;
+ double avgStep = 0;
#endif
- while(remainingRuns-- > 0) {
- Timer t;
- microSteps = 0;
+ while(remainingRuns-- > 0) {
+ Timer t;
+ microSteps = 0;
- InterpreterState state = interpreter.getState();
+ InterpreterState state = interpreter.getState();
- for(;;) {
- state = interpreter.step(true);
- microSteps++;
- if (state == USCXML_INITIALIZED) {
- t.start();
- } else if (state == USCXML_FINISHED) {
+ for(;;) {
+ state = interpreter.step(true);
+ microSteps++;
+ if (state == USCXML_INITIALIZED) {
+ t.start();
+ } else if (state == USCXML_FINISHED) {
#ifdef BUILD_PROFILING
- avgDm += interpreter._impl->_dataModel.timer.elapsed;
- interpreter._impl->_dataModel.timer.reset();
- avgStep += interpreter.timer.elapsed;
+ avgDm += interpreter._impl->_dataModel.timer.elapsed;
+ interpreter._impl->_dataModel.timer.reset();
+ avgStep += interpreter.timer.elapsed;
#endif
- }
- if (state < 0)
- break;
- }
- assert(retCode == EXIT_SUCCESS);
- t.stop();
- avg += t.elapsed;
- interpreter.reset();
- std::cout << "." << std::flush;
- }
-
- 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;
+ }
+ if (state < 0)
+ break;
+ }
+ assert(retCode == EXIT_SUCCESS);
+ t.stop();
+ avg += t.elapsed;
+ interpreter.reset();
+ std::cout << "." << std::flush;
+ }
+
+ 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;
#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;
+ 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;
#endif
}
} catch(Event e) {