diff options
author | das <das> | 2005-05-23 20:18:57 (GMT) |
---|---|---|
committer | das <das> | 2005-05-23 20:18:57 (GMT) |
commit | 2011f91ba03c5d9b3fb82ba34685f1ce9920d219 (patch) | |
tree | ba11eb43df72385108fd6605d54347b579d1d30c /generic | |
parent | 7df913256831f5a9ac25270796afd838d96f58b2 (diff) | |
download | tcl-2011f91ba03c5d9b3fb82ba34685f1ce9920d219.zip tcl-2011f91ba03c5d9b3fb82ba34685f1ce9920d219.tar.gz tcl-2011f91ba03c5d9b3fb82ba34685f1ce9920d219.tar.bz2 |
* generic/tclCmdMZ.c (Tcl_TimeObjCmd): change [time] called with a
count > 1 to return a string with a float value instead of a rounded
off integer. [Bug 1202178]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCmdMZ.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 5bc89c0..5b57b11 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -15,7 +15,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdMZ.c,v 1.120 2005/05/18 20:55:04 dgp Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.121 2005/05/23 20:18:57 das Exp $ */ #include "tclInt.h" @@ -2889,11 +2889,11 @@ Tcl_TimeObjCmd(dummy, interp, objc, objv) Tcl_Obj *CONST objv[]; /* Argument objects. */ { register Tcl_Obj *objPtr; + Tcl_Obj *objs[4]; register int i, result; int count; double totalMicroSec; Tcl_Time start, stop; - char buf[100]; if (objc == 2) { count = 1; @@ -2920,9 +2920,15 @@ Tcl_TimeObjCmd(dummy, interp, objc, objv) totalMicroSec = ( ( (double) ( stop.sec - start.sec ) ) * 1.0e6 + ( stop.usec - start.usec ) ); - sprintf(buf, "%.0f microseconds per iteration", - ((count <= 0) ? 0 : totalMicroSec/count)); - Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); + if (count <= 1) { + objs[0] = Tcl_NewIntObj((count <= 0) ? 0 : totalMicroSec); + } else { + objs[0] = Tcl_NewDoubleObj(totalMicroSec/count); + } + objs[1] = Tcl_NewStringObj("microseconds", -1); + objs[2] = Tcl_NewStringObj("per", -1); + objs[3] = Tcl_NewStringObj("iteration", -1); + Tcl_SetObjResult(interp, Tcl_NewListObj(4, objs)); return TCL_OK; } |