summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-05-09 12:52:05 +0930
committerAndrew Jeffery <andrew@aj.id.au>2018-05-14 10:08:18 +0930
commit13d0dc9fcb9e8003e6f58b8eda79b8901709bed2 (patch)
treed32b44fa3a6743b03025ed3bdfa06544faab38ec
parent52aeb314c0ebd07e5e5eaf24c0084add0e6ecaf0 (diff)
downloadpyphosphor-13d0dc9fcb9e8003e6f58b8eda79b8901709bed2.tar.gz
pyphosphor-13d0dc9fcb9e8003e6f58b8eda79b8901709bed2.zip
testpathtree: Add dataitems() stress test
Change-Id: I7493a8d2d9df6123a3d80f17b2ba268608997066 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--[-rwxr-xr-x]obmc/utils/testpathtree.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/obmc/utils/testpathtree.py b/obmc/utils/testpathtree.py
index 3c68edc..c145e47 100755..100644
--- a/obmc/utils/testpathtree.py
+++ b/obmc/utils/testpathtree.py
@@ -336,6 +336,20 @@ for i in range(0, {}):
key = '/0/a'
"""
+def iter_stress(pt):
+ for i in pt.dataitems():
+ pass
+
+iter_setup = """\
+from __main__ import iter_stress
+from obmc.utils.pathtree import PathTree
+pt = PathTree()
+for i in ('/' + '/'.join([chr(ord('a') + x)] * {}) for x in range(0, 26)):
+ for j in range(0, {}):
+ k = "{}".format(i, j)
+ pt[k] = k
+"""
+
if __name__ == "__main__":
print("Depth tests:")
for depth in range(1, 11):
@@ -350,3 +364,12 @@ if __name__ == "__main__":
stmt = "width_stress(pt, key)"
time = timeit.timeit(stmt, setup=setup)
print("\t{}: {}".format(width, time))
+ print
+ print("Iteration tests:")
+ n = 1000
+ for depth in range(1, 5):
+ for width in range(1, 5):
+ setup = iter_setup.format(depth, width, "{}/{}")
+ stmt = "iter_stress(pt)"
+ time = timeit.timeit(stmt, setup=setup, number=n)
+ print("\tdepth={}, width={}, n={}: {}".format(depth, width, n, time))
OpenPOWER on IntegriCloud