Commit b4824ad5 authored by Jérome Perrin's avatar Jérome Perrin

analyze: fix ZeroDivisionErrors when report is empty

parent 474a0559
...@@ -56,3 +56,18 @@ __main__.Object,56,1880,54.366686%,33.571429,9,303,47,1577 ...@@ -56,3 +56,18 @@ __main__.Object,56,1880,54.366686%,33.571429,9,303,47,1577
== captured.out == captured.out
) )
assert captured.err == "" assert captured.err == ""
# empty range
report(
analyze(
os.path.join(os.path.dirname(__file__), "testdata", "1.fs"),
use_dbm=False,
delta_fs=False,
tidmin="ffffffffffffffff",
tidmax=None,
),
csv=False,
)
captured = capsys.readouterr()
assert "No transactions processed\n" == captured.out
assert captured.err == ""
...@@ -95,8 +95,9 @@ def report(rep, csv=False): ...@@ -95,8 +95,9 @@ def report(rep, csv=False):
delta_fs = rep.delta_fs delta_fs = rep.delta_fs
if not csv: if not csv:
if rep.TIDS == 0: if rep.TIDS == 0:
print "# ø" print "No transactions processed"
else: return
print "# %s..%s" % (ashex(rep.tidmin), ashex(rep.tidmax)) print "# %s..%s" % (ashex(rep.tidmin), ashex(rep.tidmax))
print "Processed %d records in %d transactions" % (rep.OIDS, rep.TIDS) print "Processed %d records in %d transactions" % (rep.OIDS, rep.TIDS)
print "Average record size is %7.2f bytes" % (rep.DBYTES * 1.0 / rep.OIDS) print "Average record size is %7.2f bytes" % (rep.DBYTES * 1.0 / rep.OIDS)
......
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