summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2017-03-15 02:40:56 (GMT)
committerKevin B Kenny <kennykb@acm.org>2017-03-15 02:40:56 (GMT)
commitbbe4542d364121720a36d12051e45c8c42cf25d9 (patch)
treecc56a92667132923a5a6db8320ad3e2df4a0fd60 /generic/tclExecute.c
parentbbf9191cdf2558bb4e7571a1cf57886d79826c7e (diff)
parent89b08916f5e330151206c6ab42468f957bfd41af (diff)
downloadtcl-bbe4542d364121720a36d12051e45c8c42cf25d9.zip
tcl-bbe4542d364121720a36d12051e45c8c42cf25d9.tar.gz
tcl-bbe4542d364121720a36d12051e45c8c42cf25d9.tar.bz2
Compile [clock clicks], [clock microseconds], [clock milliseconds] and [clock seconds].
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index e3fa730..f695499 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -7664,6 +7664,39 @@ TEBCresume(
* -----------------------------------------------------------------
*/
+ case INST_CLOCK_READ:
+ { /* Read the wall clock */
+ Tcl_WideInt wval;
+ Tcl_Time now;
+ switch(TclGetUInt1AtPtr(pc+1)) {
+ case 0: /* clicks */
+#ifdef TCL_WIDE_CLICKS
+ wval = TclpGetWideClicks();
+#else
+ wval = (Tcl_WideInt) TclpGetClicks();
+#endif
+ break;
+ case 1: /* microseconds */
+ Tcl_GetTime(&now);
+ wval = (Tcl_WideInt) now.sec * 1000000 + now.usec;
+ break;
+ case 2: /* milliseconds */
+ Tcl_GetTime(&now);
+ wval = (Tcl_WideInt) now.sec * 1000 + now.usec / 1000;
+ break;
+ case 3: /* seconds */
+ Tcl_GetTime(&now);
+ wval = (Tcl_WideInt) now.sec;
+ break;
+ default:
+ Tcl_Panic("clockRead instruction with unknown clock#");
+ }
+ /* TclNewWideObj(objResultPtr, wval); doesn't exist */
+ objResultPtr = Tcl_NewWideIntObj(wval);
+ TRACE_WITH_OBJ(("=> "), objResultPtr);
+ NEXT_INST_F(2, 0, 1);
+ }
+
default:
Tcl_Panic("TclNRExecuteByteCode: unrecognized opCode %u", *pc);
} /* end of switch on opCode */