diff options
author | sebres <sebres@users.sourceforge.net> | 2019-05-21 18:04:05 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2019-05-21 18:04:05 (GMT) |
commit | c230bbb7b47c5283043c613dfa91ba0a983d5d0f (patch) | |
tree | e335184c6c014ed8204b2cb249b8ade0d9eb0fc3 | |
parent | cacd1146d090836f1fb53c0abc3294651e603ebd (diff) | |
parent | e298c2595dd09f5e4ad00b1e42251c2ac5a4f51a (diff) | |
download | tcl-c230bbb7b47c5283043c613dfa91ba0a983d5d0f.zip tcl-c230bbb7b47c5283043c613dfa91ba0a983d5d0f.tar.gz tcl-c230bbb7b47c5283043c613dfa91ba0a983d5d0f.tar.bz2 |
merge 8.6
-rw-r--r-- | generic/tclCmdMZ.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 7b83370..02f98d1 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -4546,17 +4546,20 @@ Tcl_TimeRateObjCmd( { Tcl_Obj *objarr[8], **objs = objarr; - Tcl_WideInt val; + Tcl_WideUInt usec, val; int digits; - middle -= start; /* execution time in microsecs */ + /* + * Absolute execution time in microseconds or in wide clicks. + */ + usec = (Tcl_WideUInt)(middle - start); #ifdef TCL_WIDE_CLICKS /* - * convert execution time in wide clicks to microsecs. + * convert execution time (in wide clicks) to microsecs. */ - middle *= TclpWideClickInMicrosec(); + usec *= TclpWideClickInMicrosec(); #endif /* TCL_WIDE_CLICKS */ if (!count) { /* no iterations - avoid divide by zero */ @@ -4580,10 +4583,10 @@ Tcl_TimeRateObjCmd( Tcl_WideUInt curOverhead = overhead * count; - if (middle > (Tcl_WideInt) curOverhead) { - middle -= curOverhead; + if (usec > curOverhead) { + usec -= curOverhead; } else { - middle = 0; + usec = 0; } } } else { @@ -4591,15 +4594,15 @@ Tcl_TimeRateObjCmd( * Calibration: obtaining new measurement overhead. */ - if (measureOverhead > ((double) middle) / count) { - measureOverhead = ((double) middle) / count; + if (measureOverhead > ((double) usec) / count) { + measureOverhead = ((double) usec) / count; } objs[0] = Tcl_NewDoubleObj(measureOverhead); TclNewLiteralStringObj(objs[1], "\xC2\xB5s/#-overhead"); /* mics */ objs += 2; } - val = middle / count; /* microsecs per iteration */ + val = usec / count; /* microsecs per iteration */ if (val >= 1000000) { objs[0] = Tcl_NewWideIntObj(val); } else { @@ -4614,7 +4617,7 @@ Tcl_TimeRateObjCmd( } else { digits = 1; } - objs[0] = Tcl_ObjPrintf("%.*f", digits, ((double) middle)/count); + objs[0] = Tcl_ObjPrintf("%.*f", digits, ((double) usec)/count); } objs[2] = Tcl_NewWideIntObj(count); /* iterations */ @@ -4623,11 +4626,11 @@ Tcl_TimeRateObjCmd( * Calculate speed as rate (count) per sec */ - if (!middle) { - middle++; /* Avoid divide by zero. */ + if (!usec) { + usec++; /* Avoid divide by zero. */ } if (count < (WIDE_MAX / 1000000)) { - val = (count * 1000000) / middle; + val = (count * 1000000) / usec; if (val < 100000) { if (val < 100) { digits = 3; @@ -4637,12 +4640,12 @@ Tcl_TimeRateObjCmd( digits = 1; } objs[4] = Tcl_ObjPrintf("%.*f", - digits, ((double) (count * 1000000)) / middle); + digits, ((double) (count * 1000000)) / usec); } else { objs[4] = Tcl_NewWideIntObj(val); } } else { - objs[4] = Tcl_NewWideIntObj((count / middle) * 1000000); + objs[4] = Tcl_NewWideIntObj((count / usec) * 1000000); } retRes: @@ -4651,8 +4654,8 @@ Tcl_TimeRateObjCmd( */ if (!calibrate) { - if (middle >= 1) { - objs[6] = Tcl_ObjPrintf("%.3f", (double)middle / 1000); + if (usec >= 1) { + objs[6] = Tcl_ObjPrintf("%.3f", (double)usec / 1000); } else { objs[6] = Tcl_NewWideIntObj(0); } |