diff options
-rwxr-xr-x | scripts/benchmark.py | 60 | ||||
-rwxr-xr-x | scripts/plot.py (renamed from plot.py) | 0 | ||||
-rw-r--r-- | wscript | 33 |
3 files changed, 60 insertions, 33 deletions
diff --git a/scripts/benchmark.py b/scripts/benchmark.py new file mode 100755 index 0000000..9b57a45 --- /dev/null +++ b/scripts/benchmark.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +""" +Benchmark Zix data structures. +""" + +import os +import random +import string +import subprocess + +os.chdir("build") + +# Benchmark trees + +subprocess.call(["benchmark/tree_bench", "40000", "640000"]) +subprocess.call( + [ + "../scripts/plot.py", + "tree_bench.svg", + "tree_insert.txt", + "tree_search.txt", + "tree_iterate.txt", + "tree_delete.txt", + ] +) + +# Benchmark dictionaries + +FILENAME = "gibberish.txt" +CHARACTERS = string.ascii_letters + string.digits + + +def random_word(): + """Return a random word with ASCII letters and digits""" + + wordlen = random.randrange(1, 64) + word = "" + for _ in range(wordlen): + word += random.choice(CHARACTERS) + + return word + + +if not os.path.exists(FILENAME): + print("Generating random text %s" % FILENAME) + + with open(FILENAME, "w") as out: + for i in range(1 << 20): + out.write(random_word() + "\n") + +subprocess.call(["benchmark/dict_bench", "gibberish.txt"]) +subprocess.call( + [ + "../scripts/plot.py", + "dict_bench.svg", + "dict_insert.txt", + "dict_search.txt", + ] +) diff --git a/plot.py b/scripts/plot.py index 29fffa9..29fffa9 100755 --- a/plot.py +++ b/scripts/plot.py @@ -312,36 +312,3 @@ def test(tst): with tst.group('unit') as check: for test in tests: check([os.path.join('test', test)]) - - -def bench(ctx): - os.chdir('build') - - # Benchmark trees - - subprocess.call(['benchmark/tree_bench', '40000', '640000']) - subprocess.call(['../plot.py', 'tree_bench.svg', - 'tree_insert.txt', - 'tree_search.txt', - 'tree_iterate.txt', - 'tree_delete.txt']) - - # Benchmark dictionaries - - filename = 'gibberish.txt' - if not os.path.exists(filename): - Logs.info('Generating random text %s' % filename) - import random - out = open(filename, 'w') - for i in range(1 << 20): - wordlen = random.randrange(1, 64) - word = '' - for j in range(wordlen): - word += chr(random.randrange(ord('A'), - min(ord('Z'), ord('A') + j + 1))) - out.write(word + ' ') - out.close() - - subprocess.call(['benchmark/dict_bench', 'gibberish.txt']) - subprocess.call(['../plot.py', 'dict_bench.svg', - 'dict_insert.txt', 'dict_search.txt']) |