Skip to content

Commit 47dd816

Browse files
committed
Merge remote-tracking branch 'remotes/gh-sebres/sb/_se-back-port/timerate' into sb/trunk-rewrite-clock-in-c
2 parents 75b0f7a + 42883e0 commit 47dd816

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

generic/tclCmdMZ.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,6 +4211,7 @@ Tcl_TimeRateObjCmd(
42114211
return TCL_ERROR;
42124212
}
42134213
codePtr = TclCompileObj(interp, objPtr, NULL, 0);
4214+
TclPreserveByteCode(codePtr);
42144215
}
42154216

42164217
/* get start and stop time */
@@ -4238,7 +4239,7 @@ Tcl_TimeRateObjCmd(
42384239
result = TclEvalObjEx(interp, objPtr, 0, NULL, 0);
42394240
}
42404241
if (result != TCL_OK) {
4241-
return result;
4242+
goto done;
42424243
}
42434244

42444245
/* don't check time up to threshold */
@@ -4277,6 +4278,7 @@ Tcl_TimeRateObjCmd(
42774278
if (!calibrate) {
42784279
/* minimize influence of measurement overhead */
42794280
if (overhead > 0) {
4281+
/* estimate the time of overhead (microsecs) */
42804282
Tcl_WideInt curOverhead = overhead * count;
42814283
if (middle > curOverhead) {
42824284
middle -= curOverhead;
@@ -4290,7 +4292,7 @@ Tcl_TimeRateObjCmd(
42904292
measureOverhead = (double)middle / count;
42914293
}
42924294
objs[0] = Tcl_NewDoubleObj(measureOverhead);
4293-
TclNewLiteralStringObj(objs[1], "\xC2\xB5s/#-overhead,"); /* mics */
4295+
TclNewLiteralStringObj(objs[1], "\xC2\xB5s/#-overhead"); /* mics */
42944296
objs += 2;
42954297
}
42964298

@@ -4324,15 +4326,27 @@ Tcl_TimeRateObjCmd(
43244326
objs[4] = Tcl_NewWideIntObj((count / middle) * 1000000);
43254327
}
43264328

4329+
/* estimated net execution time (in millisecs) */
4330+
if (!calibrate) {
4331+
objs[6] = Tcl_ObjPrintf("%.3f", (double)middle / 1000);
4332+
TclNewLiteralStringObj(objs[7], "nett-ms");
4333+
}
4334+
43274335
/*
43284336
* Construct the result as a list because many programs have always parsed
43294337
* as such (extracting the first element, typically).
43304338
*/
43314339

4332-
TclNewLiteralStringObj(objs[1], "\xC2\xB5s/#,"); /* mics/# */
4333-
TclNewLiteralStringObj(objs[3], "#,");
4340+
TclNewLiteralStringObj(objs[1], "\xC2\xB5s/#"); /* mics/# */
4341+
TclNewLiteralStringObj(objs[3], "#");
43344342
TclNewLiteralStringObj(objs[5], "#/sec");
4335-
Tcl_SetObjResult(interp, Tcl_NewListObj((!calibrate) ? 6 : 8, objarr));
4343+
Tcl_SetObjResult(interp, Tcl_NewListObj(8, objarr));
4344+
}
4345+
4346+
done:
4347+
4348+
if (codePtr != NULL) {
4349+
TclReleaseByteCode(codePtr);
43364350
}
43374351

43384352
return result;

0 commit comments

Comments
 (0)