fix typo
[scons.git] / bench / dependency-func.py
blob7313cf97eb44a8ebff435ec147c8ca066a6beb4e
1 # __COPYRIGHT__
3 # Benchmarks for testing the selection of dependency changed functions
4 # in src/engine/Environment.py.
7 def use_a_dict(env, dep, arg):
8 func = {
9 '1111' : dep.func1,
10 '2222' : dep.func2,
11 '3333' : dep.func3,
12 '4444' : dep.func4,
14 t = env.get_type()
15 return func[t](arg)
18 def use_if_tests(env, dep, arg):
19 t = env.get_type()
20 if t == '1111':
21 func = dep.func1
22 elif t == '2222':
23 func = dep.func2
24 elif t == '3333':
25 func = dep.func3
26 elif t == '4444':
27 func = dep.func4
28 else:
29 raise Exception("bad key %s" % t)
30 return func(arg)
33 class Environment():
34 def __init__(self, t):
35 self.t = t
36 def get_type(self):
37 return self.t
39 class Node():
40 def func1(self, arg):
41 pass
42 def func2(self, arg):
43 pass
44 def func3(self, arg):
45 pass
46 def func4(self, arg):
47 pass
49 node = Node()
51 def Func01(t):
52 """use_a_dict"""
53 env = Environment(t)
54 for i in IterationList:
55 use_a_dict(env, node, None)
57 def Func02(t):
58 """use_if_tests"""
59 env = Environment(t)
60 for i in IterationList:
61 use_if_tests(env, node, None)
65 # Data to pass to the functions on each run. Each entry is a
66 # three-element tuple:
68 # (
69 # "Label to print describing this data run",
70 # ('positional', 'arguments'),
71 # {'keyword' : 'arguments'},
72 # ),
74 class A:
75 pass
77 Data = [
79 "1",
80 ('1111',),
81 {},
84 "2",
85 ('2222',),
86 {},
89 "3",
90 ('3333',),
91 {},
94 "4",
95 ('4444',),
96 {},
100 # Local Variables:
101 # tab-width:4
102 # indent-tabs-mode:nil
103 # End:
104 # vim: set expandtab tabstop=4 shiftwidth=4: