@@ -32,10 +32,10 @@ def test_pack_random_access(self):
32
32
# sha lookup
33
33
st = time ()
34
34
sha_list = list (pdb .sha_iter ())
35
- elapsed = time () - st
35
+ elapsed = max ( time () - st , 0.001 ) # prevent zero divison errors on windows
36
36
ns = len (sha_list )
37
37
print ("PDB: looked up %i shas by index in %f s ( %f shas/s )" % (
38
- ns , elapsed , ns / ( elapsed or 1 ) ), file = sys .stderr )
38
+ ns , elapsed , ns / elapsed ), file = sys .stderr )
39
39
40
40
# sha lookup: best-case and worst case access
41
41
pdb_pack_info = pdb ._pack_info
@@ -44,13 +44,13 @@ def test_pack_random_access(self):
44
44
for sha in sha_list :
45
45
pdb_pack_info (sha )
46
46
# END for each sha to look up
47
- elapsed = time () - st
47
+ elapsed = max ( time () - st , 0.001 ) # prevent zero divison errors on windows
48
48
49
49
# discard cache
50
50
del (pdb ._entities )
51
51
pdb .entities ()
52
52
print ("PDB: looked up %i sha in %i packs in %f s ( %f shas/s )" %
53
- (ns , len (pdb .entities ()), elapsed , ns / ( elapsed or 1 ) ), file = sys .stderr )
53
+ (ns , len (pdb .entities ()), elapsed , ns / elapsed ), file = sys .stderr )
54
54
# END for each random mode
55
55
56
56
# query info and streams only
@@ -59,9 +59,9 @@ def test_pack_random_access(self):
59
59
st = time ()
60
60
for sha in sha_list [:max_items ]:
61
61
pdb_fun (sha )
62
- elapsed = time () - st
62
+ elapsed = max ( time () - st , 0.001 ) # prevent zero divison errors on windows
63
63
print ("PDB: Obtained %i object %s by sha in %f s ( %f items/s )" %
64
- (max_items , pdb_fun .__name__ .upper (), elapsed , max_items / ( elapsed or 1 ) ), file = sys .stderr )
64
+ (max_items , pdb_fun .__name__ .upper (), elapsed , max_items / elapsed ), file = sys .stderr )
65
65
# END for each function
66
66
67
67
# retrieve stream and read all
@@ -74,11 +74,11 @@ def test_pack_random_access(self):
74
74
read_len = len (stream .read ())
75
75
assert read_len == stream .size
76
76
total_size += stream .size
77
- elapsed = time () - st
77
+ elapsed = max ( time () - st , 0.001 ) # prevent zero divison errors on windows
78
78
total_kib = total_size / 1000
79
79
print ("PDB: Obtained %i streams by sha and read all bytes "
80
80
"totallying %i KiB ( %f KiB / s ) in %f s ( %f streams/s )" %
81
- (max_items , total_kib , total_kib / ( elapsed or 1 ) , elapsed , max_items / ( elapsed or 1 ) ), file = sys .stderr )
81
+ (max_items , total_kib , total_kib / elapsed , elapsed , max_items / elapsed ), file = sys .stderr )
82
82
83
83
def test_loose_correctness (self ):
84
84
"""based on the pack(s) of our packed object DB, we will just copy and verify all objects in the back
@@ -130,7 +130,7 @@ def test_correctness(self):
130
130
# END ignore old indices
131
131
# END for each index
132
132
# END for each entity
133
- elapsed = time () - st
133
+ elapsed = max ( time () - st , 0.001 ) # prevent zero divison errors on windows
134
134
print ("PDB: verified %i objects (crc=%i) in %f s ( %f objects/s )" %
135
- (count , crc , elapsed , count / ( elapsed or 1 ) ), file = sys .stderr )
135
+ (count , crc , elapsed , count / elapsed ), file = sys .stderr )
136
136
# END for each verify mode
0 commit comments