summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2017-03-15 02:39:04 (GMT)
committerKevin B Kenny <kennykb@acm.org>2017-03-15 02:39:04 (GMT)
commit43d597b30f23c04837758d424f4baa7478b7202a (patch)
tree390fedcdb66fcff575a9443bfb220573c735d4a4 /generic/tclExecute.c
parent607667f89dc9884c9bfb8e3c5380c9d5aa930d04 (diff)
downloadtcl-43d597b30f23c04837758d424f4baa7478b7202a.zip
tcl-43d597b30f23c04837758d424f4baa7478b7202a.tar.gz
tcl-43d597b30f23c04837758d424f4baa7478b7202a.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 1d3a825..4250958 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -7840,6 +7840,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 */