Commit 45bb4aaa authored by Jim Fulton's avatar Jim Fulton

Normalize ctime for tests to avoid spurios test failures in

non-standart ;) time zones.

Cleanup trailing whitespace in verbose stats output.
parent 29a522ca
...@@ -41,6 +41,9 @@ import ZEO.cache ...@@ -41,6 +41,9 @@ import ZEO.cache
from ZODB.utils import z64, u64 from ZODB.utils import z64, u64
# we assign ctime locally to facilitate test replacement!
from time import ctime
def usage(msg): def usage(msg):
print >> sys.stderr, msg print >> sys.stderr, msg
print >> sys.stderr, __doc__ print >> sys.stderr, __doc__
...@@ -250,7 +253,7 @@ class Simulation(object): ...@@ -250,7 +253,7 @@ class Simulation(object):
def report(self): def report(self):
self.nreports += 1 self.nreports += 1
args = (time.ctime(self.ts0)[4:-8], args = (ctime(self.ts0)[4:-8],
duration(self.ts1 - self.ts0), duration(self.ts1 - self.ts0),
self.loads, self.hits, self.invals, self.writes, self.loads, self.hits, self.invals, self.writes,
hitrate(self.loads, self.hits)) hitrate(self.loads, self.hits))
...@@ -267,7 +270,7 @@ class Simulation(object): ...@@ -267,7 +270,7 @@ class Simulation(object):
else: else:
self.report() self.report()
args = ( args = (
time.ctime(self.epoch)[4:-8], ctime(self.epoch)[4:-8],
duration(self.ts1 - self.epoch), duration(self.ts1 - self.epoch),
self.total_loads, self.total_loads,
self.total_hits, self.total_hits,
......
...@@ -62,6 +62,9 @@ import getopt ...@@ -62,6 +62,9 @@ import getopt
import struct import struct
from types import StringType from types import StringType
# we assign ctime locally to facilitate test replacement!
from time import ctime
def usage(msg): def usage(msg):
print >> sys.stderr, msg print >> sys.stderr, msg
print >> sys.stderr, __doc__ print >> sys.stderr, __doc__
...@@ -206,14 +209,14 @@ def main(args=None): ...@@ -206,14 +209,14 @@ def main(args=None):
bysizew[dlen] = d = bysizew.get(dlen) or {} bysizew[dlen] = d = bysizew.get(dlen) or {}
d[oid] = d.get(oid, 0) + 1 d[oid] = d.get(oid, 0) + 1
if verbose: if verbose:
print "%s %02x %s %016x %016x %c %s" % ( print "%s %02x %s %016x %016x %c%s" % (
time.ctime(ts)[4:-5], ctime(ts)[4:-5],
code, code,
oid_repr(oid), oid_repr(oid),
U64(start_tid), U64(start_tid),
U64(end_tid), U64(end_tid),
version, version,
dlen and str(dlen) or "") dlen and (' '+str(dlen)) or "")
if code & 0x70 == 0x20: if code & 0x70 == 0x20:
oids[oid] = oids.get(oid, 0) + 1 oids[oid] = oids.get(oid, 0) + 1
total_loads += 1 total_loads += 1
...@@ -224,7 +227,7 @@ def main(args=None): ...@@ -224,7 +227,7 @@ def main(args=None):
thisinterval = ts // interval thisinterval = ts // interval
h0 = he = ts h0 = he = ts
if not quiet: if not quiet:
print time.ctime(ts)[4:-5], print ctime(ts)[4:-5],
print '='*20, "Restart", '='*20 print '='*20, "Restart", '='*20
except KeyboardInterrupt: except KeyboardInterrupt:
print "\nInterrupted. Stats so far:\n" print "\nInterrupted. Stats so far:\n"
...@@ -246,8 +249,8 @@ def main(args=None): ...@@ -246,8 +249,8 @@ def main(args=None):
print "Read %s trace records (%s bytes) in %.1f seconds" % ( print "Read %s trace records (%s bytes) in %.1f seconds" % (
addcommas(records), addcommas(end_pos), rte-rt0) addcommas(records), addcommas(end_pos), rte-rt0)
print "Versions: %s records used a version" % addcommas(versions) print "Versions: %s records used a version" % addcommas(versions)
print "First time: %s" % time.ctime(t0) print "First time: %s" % ctime(t0)
print "Last time: %s" % time.ctime(te) print "Last time: %s" % ctime(te)
print "Duration: %s seconds" % addcommas(te-t0) print "Duration: %s seconds" % addcommas(te-t0)
print "Data recs: %s (%.1f%%), average size %d bytes" % ( print "Data recs: %s (%.1f%%), average size %d bytes" % (
addcommas(datarecords), addcommas(datarecords),
...@@ -326,7 +329,7 @@ def dumpbyinterval(byinterval, h0, he): ...@@ -326,7 +329,7 @@ def dumpbyinterval(byinterval, h0, he):
hr = 'n/a' hr = 'n/a'
print "%s-%s %7s %7s %7s %7s %7s" % ( print "%s-%s %7s %7s %7s %7s %7s" % (
time.ctime(h0)[4:-8], time.ctime(he)[14:-8], ctime(h0)[4:-8], ctime(he)[14:-8],
loads, hits, invals, writes, hr) loads, hits, invals, writes, hr)
def hitrate(bycode): def hitrate(bycode):
......
...@@ -537,6 +537,11 @@ Check to make sure the cache analysis scripts work. ...@@ -537,6 +537,11 @@ Check to make sure the cache analysis scripts work.
>>> import ZEO.scripts.cache_stats, ZEO.scripts.cache_simul >>> import ZEO.scripts.cache_stats, ZEO.scripts.cache_simul
>>> def ctime(t):
... return time.asctime(time.gmtime(t-3600*4))
>>> ZEO.scripts.cache_stats.ctime = ctime
>>> ZEO.scripts.cache_stats.simul = ctime
############################################################ ############################################################
Stats Stats
...@@ -1016,6 +1021,8 @@ Cleanup: ...@@ -1016,6 +1021,8 @@ Cleanup:
>>> del os.environ["ZEO_CACHE_TRACE"] >>> del os.environ["ZEO_CACHE_TRACE"]
>>> time.time = timetime >>> time.time = timetime
>>> ZEO.scripts.cache_stats.ctime = time.ctime
>>> ZEO.scripts.cache_stats.simul = time.ctime
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment