annotate tests/_perf_config.py @ 541:25b61f0a1958

Docs for _split_ns() and _split_filters()
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 29 Dec 2021 13:33:11 +0100
parents 9546d38cd3f8
children f71d34dda19f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 from __future__ import print_function
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5 import os
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 import sys
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 import timeit
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 sys.path.insert(
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 0,
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 os.path.abspath(
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 os.path.normpath(os.path.join(os.path.dirname(__file__), ".."))))
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
14
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
15 opts = sys.argv[1:]
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
16 all = not opts or "all" in opts
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
17
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18 setup = """
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19 import os
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21 import configmix
505
9e5fec21e2fb Measure quote/unquote performance
Franz Glasner <fzglas.hg@dom66.de>
parents: 501
diff changeset
22 import configmix.config
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24 TESTDATADIR = os.path.join(
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25 os.path.abspath(os.path.dirname(configmix.__file__)),
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
26 "..",
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27 "tests",
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
28 "data")
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
29
505
9e5fec21e2fb Measure quote/unquote performance
Franz Glasner <fzglas.hg@dom66.de>
parents: 501
diff changeset
30 unquote = configmix.unquote
9e5fec21e2fb Measure quote/unquote performance
Franz Glasner <fzglas.hg@dom66.de>
parents: 501
diff changeset
31 quote = configmix.quote
539
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
32 pathstr2path = configmix.pathstr2path
505
9e5fec21e2fb Measure quote/unquote performance
Franz Glasner <fzglas.hg@dom66.de>
parents: 501
diff changeset
33
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
34 cfg = configmix.load(os.path.join(TESTDATADIR, "conf_perf.py"))
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
35
539
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
36 se = u""
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
37 s1 = u"abc.def.hij"
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
38
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
39 """
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42 num = 1000000
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
43 num_quote = 1 * num
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44
539
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
45 if all or "quote" in opts or "unquote" in opts or "path" in opts:
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
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))
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
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))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
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))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
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))
539
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
50 print("pathstr2path/non-empty: %.4f" % timeit.timeit('a = pathstr2path(s1)', setup=setup, number=num_quote))
9546d38cd3f8 Refactor: the parsing of the quoted and dot-separated path string is put into a function that handles also empty inputs properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 533
diff changeset
51 print("pathstr2path/empty: %.4f" % timeit.timeit('a = pathstr2path(se)', setup=setup, number=num_quote))
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
52 print("quote/nothing: %.4f" % timeit.timeit('a = [quote(vp) for vp in (u"abc", u"def", u"hij")]', setup=setup, number=num_quote))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
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))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
54 print("="*50)
505
9e5fec21e2fb Measure quote/unquote performance
Franz Glasner <fzglas.hg@dom66.de>
parents: 501
diff changeset
55
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
56 if all or "default" in opts or "non-existing" in opts:
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
57 print("default: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"yyy", default=None)', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
58 print("default: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"yyy", default=None)', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
59 print("default: %.4f" % timeit.timeit('cfg.getvar(u"tree1.yyy", default=None)', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
60 print("default: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.yyy", default=None)', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
61 print("-"*50)
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
62
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
63 if all or "simple-string" in opts:
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
64 print("simple-string: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key4")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
65 print("simple-string: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key4")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
66 print("simple-string: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key4")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
67 print("simple-string: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key4")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
68 print("-"*50)
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
69
533
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
70 if all or "expand-string-one" in opts:
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
71 print("expand-string-one: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key11")', setup=setup, number=num))
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
72 print("expand-string-one: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key11")', setup=setup, number=num))
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
73 print("expand-string-one: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key11")', setup=setup, number=num))
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
74 print("expand-string-one: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key11")', setup=setup, number=num))
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
75 print("-"*50)
496
36ab39e3de53 A script to measure some basic performance characteristics of configmix.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
76
533
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
77 if all or "expand-string-one-noncached" in opts:
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
78 print("expand-string-one-noncached: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key12")', setup=setup, number=num))
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
79 print("expand-string-one-noncached: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key12")', setup=setup, number=num))
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
80 print("expand-string-one-noncached: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key12")', setup=setup, number=num))
e43db776f80a Perf script: "once" -> "one"
Franz Glasner <fzglas.hg@dom66.de>
parents: 532
diff changeset
81 print("expand-string-one-noncached: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key12")', setup=setup, number=num))
532
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
82 print("-"*50)
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
83
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
84 if all or "expand-string-many" in opts:
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
85 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key10")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
86 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key10")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
87 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key10")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
88 print("expand-string-many: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key10")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
89 print("-"*50)
501
1c83389fb8dd Another timing for interpolating a single string completely
Franz Glasner <fzglas.hg@dom66.de>
parents: 498
diff changeset
90
532
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
91 if all or "expand-string-many-noncached" in opts:
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
92 print("expand-string-many-noncached: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", u"key13")', setup=setup, number=num))
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
93 print("expand-string-many-noncached: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", u"key13")', setup=setup, number=num))
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
94 print("expand-string-many-noncached: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key13")', setup=setup, number=num))
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
95 print("expand-string-many-noncached: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key13")', setup=setup, number=num))
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
96 print("-"*50)
c2947ac74b0c Add timing for non-cached interpolations: using the PY: namespace
Franz Glasner <fzglas.hg@dom66.de>
parents: 514
diff changeset
97
514
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
98 if all or "expand-list" in opts:
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
99 print("expand-list: %.4f" % timeit.timeit('cfg.getvarl(u"tree1", u"tree2", "key8")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
100 print("expand-list: %.4f" % timeit.timeit('cfg.getvarl_s(u"tree1", u"tree2", "key8")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
101 print("expand-list: %.4f" % timeit.timeit('cfg.getvar(u"tree1.tree2.key8")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
102 print("expand-list: %.4f" % timeit.timeit('cfg.getvar_s(u"tree1.tree2.key8")', setup=setup, number=num))
d803321d927b Move convenient output from the performance script and command line arguments to select all or some performance numbers
Franz Glasner <fzglas.hg@dom66.de>
parents: 508
diff changeset
103 print("-"*50)