Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/_perf_config.py @ 514:d803321d927b
Move convenient output from the performance script and command line arguments to select all or some performance numbers
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 19 Dec 2021 14:05:14 +0100 |
| parents | 42935e4cb8d3 |
| children | c2947ac74b0c |
comparison
equal
deleted
inserted
replaced
| 513:599e8ade567c | 514:d803321d927b |
|---|---|
| 8 | 8 |
| 9 sys.path.insert( | 9 sys.path.insert( |
| 10 0, | 10 0, |
| 11 os.path.abspath( | 11 os.path.abspath( |
| 12 os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))) | 12 os.path.normpath(os.path.join(os.path.dirname(__file__), "..")))) |
| 13 | |
| 14 | |
| 15 opts = sys.argv[1:] | |
| 16 all = not opts or "all" in opts | |
| 13 | 17 |
| 14 setup = """ | 18 setup = """ |
| 15 import os | 19 import os |
| 16 | 20 |
| 17 import configmix | 21 import configmix |
| 30 | 34 |
| 31 """ | 35 """ |
| 32 | 36 |
| 33 | 37 |
| 34 num = 1000000 | 38 num = 1000000 |
| 35 num_quote = 3*num | 39 num_quote = 1 * num |
| 36 | 40 |
| 37 print("unquote/nothing/split: %.3f" % timeit.timeit('a = [unquote(vp) for vp in u"abc.def.hij".split(configmix.config._HIER_SEPARATOR)]', setup=setup, number=num_quote)) | 41 if all or "quote" in opts or "unquote" in opts: |
| 38 print("unquote/yes/split: %.3f" % timeit.timeit('a = [unquote(vp) for vp in u"ab%x20.def.h%x2ej".split(configmix.config._HIER_SEPARATOR)]', setup=setup, number=num_quote)) | 42 print("unquote/nothing/split: %.4f" % timeit.timeit('a = [unquote(vp) for vp in u"abc.def.hij".split(configmix.config._HIER_SEPARATOR)]', setup=setup, number=num_quote)) |
| 39 print("unquote/nothing/no-split: %.3f" % timeit.timeit('a = [unquote(vp) for vp in (u"abc," u"def", u"hij")]', setup=setup, number=num_quote)) | 43 print("unquote/yes/split: %.4f" % timeit.timeit('a = [unquote(vp) for vp in u"ab%x20.def.h%x2ej".split(configmix.config._HIER_SEPARATOR)]', setup=setup, number=num_quote)) |
| 40 print("unquote/yes/no-split: %.3f" % timeit.timeit('a = [unquote(vp) for vp in (u"ab%x20", u"def", u"h%x2ej")]', setup=setup, number=num_quote)) | 44 print("unquote/nothing/no-split: %.4f" % timeit.timeit('a = [unquote(vp) for vp in (u"abc," u"def", u"hij")]', setup=setup, number=num_quote)) |
| 41 print("quote/nothing: %.3f" % timeit.timeit('a = [quote(vp) for vp in (u"abc", u"def", u"hij")]', setup=setup, number=num_quote)) | 45 print("unquote/yes/no-split: %.4f" % timeit.timeit('a = [unquote(vp) for vp in (u"ab%x20", u"def", u"h%x2ej")]', setup=setup, number=num_quote)) |
| 42 print("quote/yes: %.3f" % timeit.timeit('a = [quote(vp) for vp in (u"ab:c", u"def", u"h.ij")]', setup=setup, number=num_quote)) | 46 print("quote/nothing: %.4f" % timeit.timeit('a = [quote(vp) for vp in (u"abc", u"def", u"hij")]', setup=setup, number=num_quote)) |
| 47 print("quote/yes: %.4f" % timeit.timeit('a = [quote(vp) for vp in (u"ab:c", u"def", u"h.ij")]', setup=setup, number=num_quote)) | |
| 48 print("="*50) | |
| 43 | 49 |
| 44 print("="*78) | 50 if all or "default" in opts or "non-existing" in opts: |
| 51 print("default: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"yyy", default=None)', setup=setup, number=num)) | |
| 52 print("default: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"yyy", default=None)', setup=setup, number=num)) | |
| 53 print("default: %.4f" % timeit.timeit('cfg.getvar(u"tree1.yyy", default=None)', setup=setup, number=num)) | |
| 54 print("default: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.yyy", default=None)', setup=setup, number=num)) | |
| 55 print("-"*50) | |
| 45 | 56 |
| 46 print("xxx: %.3f" % timeit.timeit('cfg.getvarl(u"tree1", u"yyy", default=None)', setup=setup, number=num)) | 57 if all or "simple-string" in opts: |
| 47 print("xxx: %.3f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"yyy", default=None)', setup=setup, number=num)) | 58 print("simple-string: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key4")', setup=setup, number=num)) |
| 48 print("xxx: %.3f" % timeit.timeit('cfg.getvar(u"tree1.yyy", default=None)', setup=setup, number=num)) | 59 print("simple-string: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key4")', setup=setup, number=num)) |
| 49 print("xxx: %.3f" % timeit.timeit('cfg.getvar_s(u"tree1.yyy", default=None)', setup=setup, number=num)) | 60 print("simple-string: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key4")', setup=setup, number=num)) |
| 61 print("simple-string: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key4")', setup=setup, number=num)) | |
| 62 print("-"*50) | |
| 50 | 63 |
| 51 print("xxx: %.3f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key4")', setup=setup, number=num)) | 64 if all or "expand-string-once" in opts: |
| 52 print("xxx: %.3f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key4")', setup=setup, number=num)) | 65 print("expand-string-once: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key11")', setup=setup, number=num)) |
| 53 print("xxx: %.3f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key4")', setup=setup, number=num)) | 66 print("expand-string-once: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key11")', setup=setup, number=num)) |
| 54 print("xxx: %.3f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key4")', setup=setup, number=num)) | 67 print("expand-string-once: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key11")', setup=setup, number=num)) |
| 68 print("expand-string-once: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key11")', setup=setup, number=num)) | |
| 69 print("-"*50) | |
| 55 | 70 |
| 56 print("xxx: %.3f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key10")', setup=setup, number=num)) | 71 if all or "expand-string-many" in opts: |
| 57 print("xxx: %.3f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key10")', setup=setup, number=num)) | 72 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key10")', setup=setup, number=num)) |
| 58 print("xxx: %.3f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key10")', setup=setup, number=num)) | 73 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key10")', setup=setup, number=num)) |
| 59 print("xxx: %.3f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key10")', setup=setup, number=num)) | 74 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key10")', setup=setup, number=num)) |
| 75 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key10")', setup=setup, number=num)) | |
| 76 print("-"*50) | |
| 60 | 77 |
| 61 print("xxx: %.3f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key8")', setup=setup, number=num)) | 78 if all or "expand-list" in opts: |
| 62 print("xxx: %.3f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key8")', setup=setup, number=num)) | 79 print("expand-list: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key8")', setup=setup, number=num)) |
| 63 print("xxx: %.3f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key8")', setup=setup, number=num)) | 80 print("expand-list: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key8")', setup=setup, number=num)) |
| 64 print("xxx: %.3f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key8")', setup=setup, number=num)) | 81 print("expand-list: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key8")', setup=setup, number=num)) |
| 65 | 82 print("expand-list: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key8")', setup=setup, number=num)) |
| 66 print("xxx: %.3f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key11")', setup=setup, number=num)) | 83 print("-"*50) |
| 67 print("xxx: %.3f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key11")', setup=setup, number=num)) | |
| 68 print("xxx: %.3f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key11")', setup=setup, number=num)) | |
| 69 print("xxx: %.3f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key11")', setup=setup, number=num)) | |
| 70 | |
| 71 |
