summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-02-09 13:50:27 (GMT)
committersebres <sebres@users.sourceforge.net>2017-02-09 13:50:27 (GMT)
commitd5c91a755cafe40630668464ed4e070fdd647852 (patch)
tree71a5c042d24a0725f34d7ee12fd645fa107274a6 /generic
parent3d05f0dbea4bb0c707a1ae59adae786c6d5cd43e (diff)
parentc88fb138612db4499a9e841453cd14bfd5db7224 (diff)
downloadtcl-d5c91a755cafe40630668464ed4e070fdd647852.zip
tcl-d5c91a755cafe40630668464ed4e070fdd647852.tar.gz
tcl-d5c91a755cafe40630668464ed4e070fdd647852.tar.bz2
merge sebres-trunk-timerate
Diffstat (limited to 'generic')
-rw-r--r--generic/tclClock.c9
-rw-r--r--generic/tclCmdMZ.c26
-rw-r--r--generic/tclInt.h12
3 files changed, 31 insertions, 16 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index c63f425..cf52673 100644
--- a/generic/tclClock.c
+++ b/generic/tclClock.c
@@ -2869,8 +2869,7 @@ ClockClicksObjCmd(
#endif
break;
case CLICKS_MICROS:
- Tcl_GetTime(&now);
- clicks = ((Tcl_WideInt) now.sec * 1000000) + now.usec;
+ clicks = TclpGetMicroseconds();
break;
}
@@ -2940,15 +2939,11 @@ ClockMicrosecondsObjCmd(
int objc, /* Parameter count */
Tcl_Obj *const *objv) /* Parameter values */
{
- Tcl_Time now;
-
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
- Tcl_GetTime(&now);
- Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
- ((Tcl_WideInt) now.sec * 1000000) + now.usec));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(TclpGetMicroseconds()));
return TCL_OK;
}
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index c660596..b0212c3 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4089,7 +4089,7 @@ Tcl_TimeRateObjCmd(
i++;
break;
}
- switch ((enum options) index) {
+ switch (index) {
case TMRT_EV_DIRECT:
direct = objv[i];
break;
@@ -4215,16 +4215,19 @@ usage:
}
/* get start and stop time */
-#ifndef TCL_WIDE_CLICKS
+#ifdef TCL_WIDE_CLICKS
+ start = middle = TclpGetWideClicks();
+ /* time to stop execution (in wide clicks) */
+ stop = start + (maxms * 1000 / TclpWideClickInMicrosec());
+#else
Tcl_GetTime(&now);
start = now.sec; start *= 1000000; start += now.usec;
-#else
- start = TclpGetWideClicks();
+ middle = start;
+ /* time to stop execution (in microsecs) */
+ stop = start + maxms * 1000;
#endif
/* start measurement */
- stop = start + maxms * 1000;
- middle = start;
while (1) {
/* eval single iteration */
count++;
@@ -4246,11 +4249,11 @@ usage:
if (--threshold > 0) continue;
/* check stop time reached, estimate new threshold */
- #ifndef TCL_WIDE_CLICKS
+ #ifdef TCL_WIDE_CLICKS
+ middle = TclpGetWideClicks();
+ #else
Tcl_GetTime(&now);
middle = now.sec; middle *= 1000000; middle += now.usec;
- #else
- middle = TclpGetWideClicks();
#endif
if (middle >= stop) {
break;
@@ -4274,6 +4277,11 @@ usage:
middle -= start; /* execution time in microsecs */
+ #ifdef TCL_WIDE_CLICKS
+ /* convert execution time in wide clicks to microsecs */
+ middle *= TclpWideClickInMicrosec();
+ #endif
+
/* if not calibrate */
if (!calibrate) {
/* minimize influence of measurement overhead */
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 15cb355..2ba1123 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3187,10 +3187,22 @@ MODULE_SCOPE int TclpLoadMemory(Tcl_Interp *interp, void *buffer,
MODULE_SCOPE void TclInitThreadStorage(void);
MODULE_SCOPE void TclFinalizeThreadDataThread(void);
MODULE_SCOPE void TclFinalizeThreadStorage(void);
+
#ifdef TCL_WIDE_CLICKS
MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void);
MODULE_SCOPE double TclpWideClicksToNanoseconds(Tcl_WideInt clicks);
+MODULE_SCOPE double TclpWideClickInMicrosec(void);
+#else
+# ifdef _WIN32
+# define TCL_WIDE_CLICKS 1
+MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void);
+MODULE_SCOPE double TclpWideClickInMicrosec(void);
+# define TclpWideClicksToNanoseconds(clicks) \
+ ((double)(clicks) * TclpWideClickInMicrosec() * 1000)
+# endif
#endif
+MODULE_SCOPE Tcl_WideInt TclpGetMicroseconds(void);
+
MODULE_SCOPE int TclZlibInit(Tcl_Interp *interp);
MODULE_SCOPE void * TclpThreadCreateKey(void);
MODULE_SCOPE void TclpThreadDeleteKey(void *keyPtr);