mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-20 00:03:58 +00:00
directories: update the directory benchmarks to exercise the unpack-and-repack functionality, and add optional profiling
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import os, random
|
import hotshot.stats, os, random
|
||||||
|
|
||||||
from pyutil import benchutil, randutil # http://allmydata.org/trac/pyutil
|
from pyutil import benchutil, randutil # http://allmydata.org/trac/pyutil
|
||||||
|
|
||||||
@ -85,17 +85,23 @@ def pack(N):
|
|||||||
def unpack(N):
|
def unpack(N):
|
||||||
return testdirnode._unpack_contents(packstr)
|
return testdirnode._unpack_contents(packstr)
|
||||||
|
|
||||||
def run_benchmarks():
|
def unpack_and_repack(N):
|
||||||
print "benchmarking %s" % (unpack,)
|
return testdirnode._pack_contents(testdirnode._unpack_contents(packstr))
|
||||||
benchutil.bench(unpack, initfunc=init_for_unpack, TOPXP=12)
|
|
||||||
print "benchmarking %s" % (pack,)
|
def run_benchmarks(profile=False):
|
||||||
benchutil.bench(pack, initfunc=init_for_pack, TOPXP=12)
|
for (func, initfunc) in [(unpack, init_for_unpack), (pack, init_for_pack), (unpack_and_repack, init_for_unpack)]:
|
||||||
|
print "benchmarking %s" % (func,)
|
||||||
|
benchutil.bench(unpack_and_repack, initfunc=init_for_unpack, TOPXP=12, profile=profile, profresults="bench_dirnode.prof")
|
||||||
|
|
||||||
|
def print_stats():
|
||||||
|
s = hotshot.stats.load("bench_dirnode.prof")
|
||||||
|
s.strip_dirs().sort_stats("time").print_stats(32)
|
||||||
|
|
||||||
def prof_benchmarks():
|
def prof_benchmarks():
|
||||||
import hotshot
|
# This requires pyutil >= v1.3.34.
|
||||||
prof = hotshot.Profile("bench_dirnode.prof")
|
run_benchmarks(profile=True)
|
||||||
prof.runcall(run_benchmarks)
|
|
||||||
prof.close()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run_benchmarks()
|
run_benchmarks()
|
||||||
|
# prof_benchmarks()
|
||||||
|
# print_stats()
|
||||||
|
Reference in New Issue
Block a user