summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xtest/all_benchmarks.py75
1 files changed, 35 insertions, 40 deletions
diff --git a/test/all_benchmarks.py b/test/all_benchmarks.py
index 84d6817d..e1b47142 100755
--- a/test/all_benchmarks.py
+++ b/test/all_benchmarks.py
@@ -14,45 +14,40 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-"""Run all the tests inside the test/ directory as a test suite."""
+"""
+Run all the benchmarks inside this directory.
+Usage: ./all_benchmarks.py [count] [regexp-filters...]
+"""
+
+import os
+import re
+import sys
+import time
+
 if __name__ == '__main__':
-	from re import compile
-	from test import *
-	from time import time
-	from types import FunctionType as function
-	from sys import argv
-	bms = []
-	try:
-		n = int(argv[1])
-	except IndexError:
-		n = 10
-	if len(argv) > 2:
-		args = [compile(re) for re in argv[2:]]
-		def allow(name):
-			for re in args:
-				if re.search(name):
-					return True
+	count   = int(sys.argv[1]) if len(sys.argv) > 1 else 10
+	regexes = [re.compile(fltr) for fltr in sys.argv[2:]]
+	modules = (fname[:-3] for fname in os.listdir(sys.path[0]) \
+			if fname[:3] == 'bm_' and fname[-3:] == '.py')
+
+	benchmarks = []  # find all benchmark (class, methodname) pairs
+	for val in [__import__(module) for module in modules]:
+		for cls in vars(val).values():
+			if type(cls) == type:
+				for methodname in vars(cls):
+					if methodname.startswith('bm_'):
+						benchmarks.append((cls, methodname))
+
+	for cls, methodname in benchmarks:
+		full_method_name = "{0}.{1}".format(cls.__name__, methodname)
+		if all(re.search(full_method_name) for re in regexes):
+			method = getattr(cls(), methodname)
+			t1 = time.time()
+			try:
+				method(count)
+			except:
+				print("{0} failed!".format(full_method_name))
+				raise
 			else:
-				return False
-	else:
-		allow = lambda name: True
-	for key, val in vars().copy().items():
-		if key.startswith('bm_'):
-			bms.extend(v for k,v in vars(val).items() if type(v) == type)
-	for bmclass in bms:
-		for attrname in vars(bmclass):
-			if not attrname.startswith('bm_'):
-				continue
-			bmobj = bmclass()
-			t1 = time()
-			method = getattr(bmobj, attrname)
-			methodname = "{0}.{1}".format(bmobj.__class__.__name__, method.__name__)
-			if allow(methodname):
-				try:
-					method(n)
-				except:
-					print("{0} failed!".format(methodname))
-					raise
-				else:
-					t2 = time()
-					print("{0:60}: {1:10}s".format(methodname, t2 - t1))
+				t2 = time.time()
+				print("{0:60}: {1:10}s".format(full_method_name, t2 - t1))
lame the previous revision' href='/akkartik/mu/blame/html/subx/056write.subx.html?h=hlt&id=044b4130214f9dbe0d9d9990a3b9c3fa2f0a1e45'>^
ac07e589 ^



104e521c ^
































6e181e7f ^
104e521c ^
c56d803c ^















d1c9392a ^

14a38052 ^


d1c9392a ^
c56d803c ^
14a38052 ^

ebd35521 ^
ac07e589 ^
14a38052 ^
d1c9392a ^
5e27c7f1 ^
901ae474 ^
5e27c7f1 ^

ac07e589 ^
9309600c ^
ac07e589 ^
5e27c7f1 ^

ac07e589 ^

5e27c7f1 ^
ac07e589 ^
5e27c7f1 ^
ac07e589 ^
5e27c7f1 ^








ac07e589 ^
5e27c7f1 ^
ac07e589 ^
5e27c7f1 ^
ac07e589 ^
5e27c7f1 ^

ac07e589 ^
5e27c7f1 ^
ac07e589 ^
5e27c7f1 ^

ac07e589 ^
5e27c7f1 ^

9309600c ^
5e27c7f1 ^
ac07e589 ^
5e27c7f1 ^
ac07e589 ^
5e27c7f1 ^




39d718af ^
14a38052 ^
ac07e589 ^
14a38052 ^

d1c9392a ^
6e181e7f ^









































14a38052 ^
6e181e7f ^
14a38052 ^
6e181e7f ^

14a38052 ^
6e181e7f ^

14a38052 ^
6e181e7f ^
14a38052 ^
ac07e589 ^
6e181e7f ^
14a38052 ^
6e181e7f ^

381d80f8 ^
6e181e7f ^
ac07e589 ^
381d80f8 ^
ac07e589 ^
381d80f8 ^
ac07e589 ^
381d80f8 ^


6e181e7f ^












104e521c ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230