diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-01-20 10:50:37 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-01-20 10:50:37 +0000 |
commit | 669695c1fb3bdc8f6a169ddd2c1eb2bf10fb6833 (patch) | |
tree | c927ec8c68067e0b8603b2953da27c2ab5b25aa4 /speed-test | |
parent | 206fb1529bf3bef9c51e9c47dd5b3fa053c485ba (diff) | |
parent | 42d9d6c7d048580e06cab7003db5fdd61a0a3f11 (diff) | |
download | larch-669695c1fb3bdc8f6a169ddd2c1eb2bf10fb6833.tar.gz |
Fix speed-test
Diffstat (limited to 'speed-test')
-rwxr-xr-x | speed-test | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -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,14 +73,16 @@ 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, - node_store=larch.NodeStoreMemory) + 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, - dirname=location) + forest = larch.open_forest( + allow_writes=True, key_size=key_size, node_size=node_size, + dirname=location) tree = forest.new_tree() @@ -144,7 +146,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' % \ |