diff options
Diffstat (limited to 'generic/tclCmdMZ.c')
-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; } |