Commit e47e829f 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 9d785e3f
...@@ -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
...@@ -597,26 +602,26 @@ Check to make sure the cache analysis scripts work. ...@@ -597,26 +602,26 @@ Check to make sure the cache analysis scripts work.
>>> ZEO.scripts.cache_stats.main('-v cache.trace'.split()) >>> ZEO.scripts.cache_stats.main('-v cache.trace'.split())
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
loads hits inv(h) writes hitrate loads hits inv(h) writes hitrate
Jul 11 12:11:41 00 '' 0000000000000000 0000000000000000 - Jul 11 12:11:41 00 '' 0000000000000000 0000000000000000 -
Jul 11 12:11-11 0 0 0 0 n/a Jul 11 12:11-11 0 0 0 0 n/a
Jul 11 12:11:41 ==================== Restart ==================== Jul 11 12:11:41 ==================== Restart ====================
Jul 11 12:11:42 10 1065 0000000000000002 0000000000000000 - Jul 11 12:11:42 10 1065 0000000000000002 0000000000000000 -
Jul 11 12:11:42 52 1065 0000000000000002 0000000000000000 - 245 Jul 11 12:11:42 52 1065 0000000000000002 0000000000000000 - 245
Jul 11 12:11:43 20 947 0000000000000000 0000000000000000 - Jul 11 12:11:43 20 947 0000000000000000 0000000000000000 -
Jul 11 12:11:43 52 947 0000000000000002 0000000000000000 - 602 Jul 11 12:11:43 52 947 0000000000000002 0000000000000000 - 602
Jul 11 12:11:44 20 124b 0000000000000000 0000000000000000 - Jul 11 12:11:44 20 124b 0000000000000000 0000000000000000 -
Jul 11 12:11:44 52 124b 0000000000000002 0000000000000000 - 1418 Jul 11 12:11:44 52 124b 0000000000000002 0000000000000000 - 1418
... ...
Jul 11 15:14:55 52 10cc 00000000000003e9 0000000000000000 - 1306 Jul 11 15:14:55 52 10cc 00000000000003e9 0000000000000000 - 1306
Jul 11 15:14:56 20 18a7 0000000000000000 0000000000000000 - Jul 11 15:14:56 20 18a7 0000000000000000 0000000000000000 -
Jul 11 15:14:56 52 18a7 00000000000003e9 0000000000000000 - 1610 Jul 11 15:14:56 52 18a7 00000000000003e9 0000000000000000 - 1610
Jul 11 15:14:57 22 18b5 000000000000031d 0000000000000000 - 1636 Jul 11 15:14:57 22 18b5 000000000000031d 0000000000000000 - 1636
Jul 11 15:14:58 20 b8a 0000000000000000 0000000000000000 - Jul 11 15:14:58 20 b8a 0000000000000000 0000000000000000 -
Jul 11 15:14:58 52 b8a 00000000000003e9 0000000000000000 - 838 Jul 11 15:14:58 52 b8a 00000000000003e9 0000000000000000 - 838
Jul 11 15:14:59 22 1085 0000000000000357 0000000000000000 - 217 Jul 11 15:14:59 22 1085 0000000000000357 0000000000000000 - 217
Jul 11 15:00-14 818 292 30 608 35.7% Jul 11 15:00-14 818 292 30 608 35.7%
Jul 11 15:15:00 22 1072 000000000000037e 0000000000000000 - 204 Jul 11 15:15:00 22 1072 000000000000037e 0000000000000000 - 204
Jul 11 15:15:01 20 16c5 0000000000000000 0000000000000000 - Jul 11 15:15:01 20 16c5 0000000000000000 0000000000000000 -
Jul 11 15:15:01 52 16c5 00000000000003e9 0000000000000000 - 1712 Jul 11 15:15:01 52 16c5 00000000000003e9 0000000000000000 - 1712
Jul 11 15:15-15 2 1 0 1 50.0% Jul 11 15:15-15 2 1 0 1 50.0%
<BLANKLINE> <BLANKLINE>
...@@ -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