Update of /cvsroot/jython/jython/org/python/modules
In directory usw-pr-cvs1:/tmp/cvs-serv29861
Modified Files:
time.java
Log Message:
clock(): Patch by brian zimmer to make time.clock() correctly return
the elapsed time from the first call to time.clock()
Index: time.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/modules/time.java,v
retrieving revision 2.13
retrieving revision 2.14
diff -C2 -r2.13 -r2.14
*** time.java 2001/03/04 17:39:38 2.13
--- time.java 2001/04/17 19:03:02 2.14
***************
*** 39,42 ****
--- 39,44 ----
case 0:
return Py.newFloat(time.time$());
+ case 1:
+ return Py.newFloat(time.clock$());
default:
throw argCountError(0);
***************
*** 96,100 ****
public static void classDictInit(PyObject dict) {
dict.__setitem__("time", new TimeFunctions("time", 0, 0));
! dict.__setitem__("clock", new TimeFunctions("clock", 0, 0));
// calculate the static variables tzname, timezone, altzone, daylight
--- 98,102 ----
public static void classDictInit(PyObject dict) {
dict.__setitem__("time", new TimeFunctions("time", 0, 0));
! dict.__setitem__("clock", new TimeFunctions("clock", 1, 0));
// calculate the static variables tzname, timezone, altzone, daylight
***************
*** 143,149 ****
}
! /*public static double clock() {
! return System.currentTimeMillis()/1000.0;
! }*/
private static void throwValueError(String msg) {
--- 145,156 ----
}
! private static double __initialclock__ = 0.0;
! public static double clock$() {
! if(__initialclock__ == 0.0) {
! // set on the first call
! __initialclock__ = time$();
! }
! return time$() - __initialclock__;
! }
private static void throwValueError(String msg) {
|