[Zope3-checkins]
SVN: Zope3/branches/3.2/src/zope/testbrowser/browser.py
backport bug fix for testbrowser timing code (revision 66155)
Benji York
benji at zope.com
Fri Mar 24 17:29:20 EST 2006
Log message for revision 66157:
backport bug fix for testbrowser timing code (revision 66155)
Changed:
U Zope3/branches/3.2/src/zope/testbrowser/browser.py
-=-
Modified: Zope3/branches/3.2/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/branches/3.2/src/zope/testbrowser/browser.py 2006-03-24 22:24:14 UTC (rev 66156)
+++ Zope3/branches/3.2/src/zope/testbrowser/browser.py 2006-03-24 22:29:19 UTC (rev 66157)
@@ -16,16 +16,17 @@
$Id$
"""
__docformat__ = "reStructuredText"
+from test import pystone
from zope.testbrowser import interfaces
import ClientForm
+import StringIO
import mechanize
import operator
import pullparser
import re
-import StringIO
+import sys
import time
import urllib2
-from test import pystone
try:
from zope import interface
@@ -104,14 +105,22 @@
self._pystones_per_second = pystone.pystones(pystone.LOOPS/10)[1]
return self._pystones_per_second
+ def _getTime(self):
+ if sys.platform.startswith('win'):
+ # Windows' time.clock gives us high-resolution wall-time
+ return time.clock()
+ else:
+ # everyone else uses time.time
+ return time.time()
+
def start(self):
"""Begin a timing period"""
- self.start_time = time.clock()
+ self.start_time = self._getTime()
self.end_time = None
def stop(self):
"""End a timing period"""
- self.end_time = time.clock()
+ self.end_time = self._getTime()
@property
def elapsedSeconds(self):
@@ -121,7 +130,7 @@
the end is the current time.
"""
if self.end_time is None:
- end_time = time.clock()
+ end_time = self._getTime()
else:
end_time = self.end_time
return end_time - self.start_time
More information about the Zope3-Checkins
mailing list