summaryrefslogtreecommitdiff
path: root/speed-test
diff options
context:
space:
mode:
authorAntoine Brenner <brenner+obnam@gymglish.com>2013-01-16 22:58:35 +0100
committerAntoine Brenner <brenner+obnam@gymglish.com>2013-01-16 22:58:35 +0100
commit42d9d6c7d048580e06cab7003db5fdd61a0a3f11 (patch)
tree6fe572dc8904d0b487755ccadeae08db557da01c /speed-test
parent206fb1529bf3bef9c51e9c47dd5b3fa053c485ba (diff)
parent76fdb08a8660fc2abe7caecbd2ffca98c9ff06f5 (diff)
downloadlarch-42d9d6c7d048580e06cab7003db5fdd61a0a3f11.tar.gz
Repair non-working example.py and speed-test
The introduction of the allow_writes parameter in larch/forest.py:open_forest() broke example.py and speed-test. Just adding the parameter to the open_forest calls was not enough to fix the issue. This patch fixes the issue by adding the allow_writes parameter where it is needed beyond the open_forest calls. Most notably, this patch changes the __init__ signature of the abstract base class larch.NodeStore from __init__(self, node_size, codec) to __init__(self, allow_writes, node_size, codec) This mimicks the current signatures of NodeStoreDisk and NodeStoreMemory, which include the use of allow_writes as first parameter, and which seem required to actually create a forest anyway since forest.py creates node_store instances with allow_writes as first parameter in open_forest
Diffstat (limited to 'speed-test')
-rwxr-xr-xspeed-test14
1 files changed, 9 insertions, 5 deletions
diff --git a/speed-test b/speed-test
index 5351a82..4d6ffab 100755
--- a/speed-test
+++ b/speed-test
@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Excercise my B-tree implementation, for simple benchmarking purposes.
-# The benchmark gets a location and an operation count as command line
-# arguments.
+# The benchmark gets a location and nb of keys to use as command line
+# arguments --location=LOCATION and --keys=KEYS.
#
# If the location is the empty string, an in-memory node store is used.
# Otherwise it must be a non-existent directory name.
@@ -73,13 +73,13 @@ class SpeedTest(cliapp.Application):
raise Exception('You must set number of keys with --keys')
if not location:
- forest = larch.open_forest(key_size=key_size, node_size=node_size,
+ forest = larch.open_forest(allow_writes=True, key_size=key_size, node_size=node_size,
node_store=larch.NodeStoreMemory)
else:
if os.path.exists(location):
raise Exception('%s exists already' % location)
os.mkdir(location)
- forest = larch.open_forest(key_size=key_size, node_size=node_size,
+ forest = larch.open_forest(allow_writes=True, key_size=key_size, node_size=node_size,
dirname=location)
tree = forest.new_tree()
@@ -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' % \