summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2019-05-16 17:49:25 (GMT)
committersebres <sebres@users.sourceforge.net>2019-05-16 17:49:25 (GMT)
commitccc592df50d217757d74cb343d046a92d76860c1 (patch)
tree83d8d643beb85dbf2d15c7b95383e13afe5c5ed8 /generic
parent8094d33e4331c3f61d015b91018908fa6fb60b96 (diff)
downloadtcl-ccc592df50d217757d74cb343d046a92d76860c1.zip
tcl-ccc592df50d217757d74cb343d046a92d76860c1.tar.gz
tcl-ccc592df50d217757d74cb343d046a92d76860c1.tar.bz2
timerate: allow continue from measurement cycle (used for conditional flow control of iterations);
more gentle evaluation behaviour, similar to a cycle now (also avoids extra overhead to set result to interp, etc.); todo: rewrite optimization of INST_DONE using last-instruction pointer or optimization flags for compile of iteration (if sebres's perf-branch gets merged).
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index fe5e51c..6be5087 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4193,6 +4193,14 @@ Tcl_TimeRateObjCmd(
}
codePtr = TclCompileObj(interp, objPtr, NULL, 0);
TclPreserveByteCode(codePtr);
+ /*
+ * Replace last compiled done instruction with continue: it's a part of
+ * iteration, this way evaluation will be more similar to a cycle (also
+ * avoids extra overhead to set result to interp, etc.)
+ */
+ if (codePtr->codeStart[codePtr->numCodeBytes-1] == INST_DONE) {
+ codePtr->codeStart[codePtr->numCodeBytes-1] = INST_CONTINUE;
+ }
}
/*
@@ -4237,23 +4245,25 @@ Tcl_TimeRateObjCmd(
} else { /* eval */
result = TclEvalObjEx(interp, objPtr, 0, NULL, 0);
}
- if (result != TCL_OK) {
- /*
- * Allow break from measurement cycle (used for conditional
- * stop).
- */
+ /*
+ * Allow break and continue from measurement cycle (used for
+ * conditional stop and flow control of iterations).
+ */
- if (result != TCL_BREAK) {
+ switch (result) {
+ case TCL_OK:
+ break;
+ case TCL_BREAK:
+ /*
+ * Force stop immediately.
+ */
+ threshold = 1;
+ maxcnt = 0;
+ case TCL_CONTINUE:
+ result = TCL_OK;
+ break;
+ default:
goto done;
- }
-
- /*
- * Force stop immediately.
- */
-
- threshold = 1;
- maxcnt = 0;
- result = TCL_OK;
}
/*