Mercurial > hgrepos > Python > libs > ConfigMix
comparison tests/_perf_config.py @ 539:9546d38cd3f8
Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 28 Dec 2021 17:28:19 +0100 |
| parents | e43db776f80a |
| children | f71d34dda19f |
comparison
equal
deleted
inserted
replaced
| 538:e85d1eddf539 | 539:9546d38cd3f8 |
|---|---|
| 27 "tests", | 27 "tests", |
| 28 "data") | 28 "data") |
| 29 | 29 |
| 30 unquote = configmix.unquote | 30 unquote = configmix.unquote |
| 31 quote = configmix.quote | 31 quote = configmix.quote |
| 32 pathstr2path = configmix.pathstr2path | |
| 32 | 33 |
| 33 cfg = configmix.load(os.path.join(TESTDATADIR, "conf_perf.py")) | 34 cfg = configmix.load(os.path.join(TESTDATADIR, "conf_perf.py")) |
| 35 | |
| 36 se = u"" | |
| 37 s1 = u"abc.def.hij" | |
| 34 | 38 |
| 35 """ | 39 """ |
| 36 | 40 |
| 37 | 41 |
| 38 num = 1000000 | 42 num = 1000000 |
| 39 num_quote = 1 * num | 43 num_quote = 1 * num |
| 40 | 44 |
| 41 if all or "quote" in opts or "unquote" in opts: | 45 if all or "quote" in opts or "unquote" in opts or "path" in opts: |
| 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)) | 46 print("unquote/nothing/split: %.4f" % timeit.timeit('a = tuple([unquote(vp) for vp in u"abc.def.hij".split(configmix.config._HIER_SEPARATOR)])', 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)) | 47 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)) |
| 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)) | 48 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)) |
| 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)) | 49 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)) |
| 50 print("pathstr2path/non-empty: %.4f" % timeit.timeit('a = pathstr2path(s1)', setup=setup, number=num_quote)) | |
| 51 print("pathstr2path/empty: %.4f" % timeit.timeit('a = pathstr2path(se)', 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)) | 52 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)) | 53 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) | 54 print("="*50) |
| 49 | 55 |
| 50 if all or "default" in opts or "non-existing" in opts: | 56 if all or "default" in opts or "non-existing" in opts: |
