summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example.py8
-rw-r--r--larch/forest_tests.py2
-rw-r--r--larch/nodestore_memory_tests.py2
-rw-r--r--larch/tree_tests.py6
-rwxr-xr-xspeed-test6
5 files changed, 14 insertions, 10 deletions
diff --git a/example.py b/example.py
index ecfa42d..c6bce64 100644
--- a/example.py
+++ b/example.py
@@ -33,7 +33,7 @@ def compute(filename):
return md5.hexdigest()
-def open_tree(dirname, allow_writes=False):
+def open_tree(allow_writes, dirname):
key_size = len(compute('/dev/null'))
node_size = 4096
@@ -47,7 +47,7 @@ def open_tree(dirname, allow_writes=False):
def add(filenames):
- forest, tree = open_tree('example.tree', allow_writes=True)
+ forest, tree = open_tree(allow_writes=True, dirname='example.tree')
for filename in filenames:
checksum = compute(filename)
tree.insert(checksum, filename)
@@ -55,14 +55,14 @@ def add(filenames):
def find(checksums):
- forest, tree = open_tree('example.tree')
+ forest, tree = open_tree(allow_writes=False, dirname='example.tree')
for checksum in checksums:
filename = tree.lookup(checksum)
print checksum, filename
def list_checksums():
- forest, tree = open_tree('example.tree')
+ forest, tree = open_tree(allow_writes=False, dirname='example.tree')
key_size = len(compute('/dev/null'))
minkey = '0' * key_size
maxkey = 'f' * key_size
diff --git a/larch/forest_tests.py b/larch/forest_tests.py
index 9a786bd..a7c9677 100644
--- a/larch/forest_tests.py
+++ b/larch/forest_tests.py
@@ -26,7 +26,7 @@ class ForestTests(unittest.TestCase):
def setUp(self):
self.codec = larch.NodeCodec(3)
- self.ns = larch.NodeStoreMemory(64, self.codec)
+ self.ns = larch.NodeStoreMemory(allow_writes=True, node_size=64, codec=self.codec)
self.forest = larch.Forest(self.ns)
def test_new_node_ids_grow(self):
diff --git a/larch/nodestore_memory_tests.py b/larch/nodestore_memory_tests.py
index eecb905..8c210db 100644
--- a/larch/nodestore_memory_tests.py
+++ b/larch/nodestore_memory_tests.py
@@ -25,5 +25,5 @@ class NodeStoreMemoryTests(unittest.TestCase, larch.NodeStoreTests):
def setUp(self):
self.node_size = 4096
self.codec = larch.NodeCodec(self.key_bytes)
- self.ns = nodestore_memory.NodeStoreMemory(self.node_size, self.codec)
+ self.ns = nodestore_memory.NodeStoreMemory(allow_writes=True, node_size=self.node_size, codec=self.codec)
diff --git a/larch/tree_tests.py b/larch/tree_tests.py
index 86895f0..8a4a4e9 100644
--- a/larch/tree_tests.py
+++ b/larch/tree_tests.py
@@ -67,7 +67,7 @@ class BTreeTests(unittest.TestCase):
# We use a small node size so that all code paths are traversed
# during testing. Use coverage.py to make sure they do.
self.codec = larch.NodeCodec(3)
- self.ns = DummyNodeStore(64, self.codec)
+ self.ns = DummyNodeStore(allow_writes=True, node_size=64, codec=self.codec)
self.forest = DummyForest()
self.tree = larch.BTree(self.forest, self.ns, None)
self.dump = False
@@ -549,7 +549,7 @@ class BTreeDecrementTests(unittest.TestCase):
# We use a small node size so that all code paths are traversed
# during testing. Use coverage.py to make sure they do.
self.codec = larch.NodeCodec(3)
- self.ns = DummyNodeStore(64, self.codec)
+ self.ns = DummyNodeStore(allow_writes=True, node_size=64, codec=self.codec)
self.forest = DummyForest()
self.tree = larch.BTree(self.forest, self.ns, None)
self.tree.insert('foo', 'bar')
@@ -574,7 +574,7 @@ class BTreeDecrementTests(unittest.TestCase):
class BTreeBalanceTests(unittest.TestCase):
def setUp(self):
- ns = DummyNodeStore(4096, larch.NodeCodec(2))
+ ns = DummyNodeStore(allow_writes=True, node_size=4096, codec=larch.NodeCodec(2))
forest = DummyForest()
self.tree = larch.BTree(forest, ns, None)
self.keys = ['%02d' % i for i in range(10)]
diff --git a/speed-test b/speed-test
index 791fdbc..4d6ffab 100755
--- a/speed-test
+++ b/speed-test
@@ -144,7 +144,11 @@ class SpeedTest(cliapp.Application):
# Report
def speed(result, i):
- return n / (result[i] - looptime[i])
+ if result[i] == looptime[i]:
+ # computer too fast for the number of "keys" used...
+ return float("infinity")
+ else:
+ return n / (result[i] - looptime[i])
def report(label, result):
cpu, wall = result
print '%-16s: %5.3f s (%8.1f/s) CPU; %5.3f s (%8.1f/s) wall' % \