blob: d93802c187aba902d059a44c1b433a53e1b0928c [file] [log] [blame]
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001from pybench import Test
2
3class TupleSlicing(Test):
4
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005 version = 2.0
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00006 operations = 3 * 25 * 10 * 7
Thomas Wouters0e3f5912006-08-11 14:57:12 +00007 rounds = 500
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00008
9 def test(self):
10
11 r = range(25)
Thomas Wouters0e3f5912006-08-11 14:57:12 +000012 t = tuple(range(100))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000013
Guido van Rossum805365e2007-05-07 22:24:25 +000014 for i in range(self.rounds):
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000015
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000016 for j in r:
17
18 m = t[50:]
19 m = t[:25]
20 m = t[50:55]
21 m = t[:-1]
22 m = t[1:]
23 m = t[-10:]
24 m = t[:10]
25
26 m = t[50:]
27 m = t[:25]
28 m = t[50:55]
29 m = t[:-1]
30 m = t[1:]
31 m = t[-10:]
32 m = t[:10]
33
34 m = t[50:]
35 m = t[:25]
36 m = t[50:55]
37 m = t[:-1]
38 m = t[1:]
39 m = t[-10:]
40 m = t[:10]
41
42 m = t[50:]
43 m = t[:25]
44 m = t[50:55]
45 m = t[:-1]
46 m = t[1:]
47 m = t[-10:]
48 m = t[:10]
49
50 m = t[50:]
51 m = t[:25]
52 m = t[50:55]
53 m = t[:-1]
54 m = t[1:]
55 m = t[-10:]
56 m = t[:10]
57
58 m = t[50:]
59 m = t[:25]
60 m = t[50:55]
61 m = t[:-1]
62 m = t[1:]
63 m = t[-10:]
64 m = t[:10]
65
66 m = t[50:]
67 m = t[:25]
68 m = t[50:55]
69 m = t[:-1]
70 m = t[1:]
71 m = t[-10:]
72 m = t[:10]
73
74 m = t[50:]
75 m = t[:25]
76 m = t[50:55]
77 m = t[:-1]
78 m = t[1:]
79 m = t[-10:]
80 m = t[:10]
81
82 m = t[50:]
83 m = t[:25]
84 m = t[50:55]
85 m = t[:-1]
86 m = t[1:]
87 m = t[-10:]
88 m = t[:10]
89
90 m = t[50:]
91 m = t[:25]
92 m = t[50:55]
93 m = t[:-1]
94 m = t[1:]
95 m = t[-10:]
96 m = t[:10]
97
98 m = t[50:]
99 m = t[:25]
100 m = t[50:55]
101 m = t[:-1]
102 m = t[1:]
103 m = t[-10:]
104 m = t[:10]
105
106 m = t[50:]
107 m = t[:25]
108 m = t[50:55]
109 m = t[:-1]
110 m = t[1:]
111 m = t[-10:]
112 m = t[:10]
113
114 m = t[50:]
115 m = t[:25]
116 m = t[50:55]
117 m = t[:-1]
118 m = t[1:]
119 m = t[-10:]
120 m = t[:10]
121
122 m = t[50:]
123 m = t[:25]
124 m = t[50:55]
125 m = t[:-1]
126 m = t[1:]
127 m = t[-10:]
128 m = t[:10]
129
130 m = t[50:]
131 m = t[:25]
132 m = t[50:55]
133 m = t[:-1]
134 m = t[1:]
135 m = t[-10:]
136 m = t[:10]
137
138 m = t[50:]
139 m = t[:25]
140 m = t[50:55]
141 m = t[:-1]
142 m = t[1:]
143 m = t[-10:]
144 m = t[:10]
145
146 m = t[50:]
147 m = t[:25]
148 m = t[50:55]
149 m = t[:-1]
150 m = t[1:]
151 m = t[-10:]
152 m = t[:10]
153
154 m = t[50:]
155 m = t[:25]
156 m = t[50:55]
157 m = t[:-1]
158 m = t[1:]
159 m = t[-10:]
160 m = t[:10]
161
162 m = t[50:]
163 m = t[:25]
164 m = t[50:55]
165 m = t[:-1]
166 m = t[1:]
167 m = t[-10:]
168 m = t[:10]
169
170 m = t[50:]
171 m = t[:25]
172 m = t[50:55]
173 m = t[:-1]
174 m = t[1:]
175 m = t[-10:]
176 m = t[:10]
177
178 m = t[50:]
179 m = t[:25]
180 m = t[50:55]
181 m = t[:-1]
182 m = t[1:]
183 m = t[-10:]
184 m = t[:10]
185
186 m = t[50:]
187 m = t[:25]
188 m = t[50:55]
189 m = t[:-1]
190 m = t[1:]
191 m = t[-10:]
192 m = t[:10]
193
194 m = t[50:]
195 m = t[:25]
196 m = t[50:55]
197 m = t[:-1]
198 m = t[1:]
199 m = t[-10:]
200 m = t[:10]
201
202 m = t[50:]
203 m = t[:25]
204 m = t[50:55]
205 m = t[:-1]
206 m = t[1:]
207 m = t[-10:]
208 m = t[:10]
209
210 m = t[50:]
211 m = t[:25]
212 m = t[50:55]
213 m = t[:-1]
214 m = t[1:]
215 m = t[-10:]
216 m = t[:10]
217
218 m = t[50:]
219 m = t[:25]
220 m = t[50:55]
221 m = t[:-1]
222 m = t[1:]
223 m = t[-10:]
224 m = t[:10]
225
226 m = t[50:]
227 m = t[:25]
228 m = t[50:55]
229 m = t[:-1]
230 m = t[1:]
231 m = t[-10:]
232 m = t[:10]
233
234 m = t[50:]
235 m = t[:25]
236 m = t[50:55]
237 m = t[:-1]
238 m = t[1:]
239 m = t[-10:]
240 m = t[:10]
241
242 m = t[50:]
243 m = t[:25]
244 m = t[50:55]
245 m = t[:-1]
246 m = t[1:]
247 m = t[-10:]
248 m = t[:10]
249
250 m = t[50:]
251 m = t[:25]
252 m = t[50:55]
253 m = t[:-1]
254 m = t[1:]
255 m = t[-10:]
256 m = t[:10]
257
258 def calibrate(self):
259
260 r = range(25)
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000261 t = tuple(range(100))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000262
Guido van Rossum805365e2007-05-07 22:24:25 +0000263 for i in range(self.rounds):
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000264 for j in r:
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000265 pass
266
267class SmallTuples(Test):
268
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000269 version = 2.0
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000270 operations = 5*(1 + 3 + 6 + 2)
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000271 rounds = 90000
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000272
273 def test(self):
274
Guido van Rossum805365e2007-05-07 22:24:25 +0000275 for i in range(self.rounds):
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000276
277 t = (1,2,3,4,5,6)
278
279 a,b,c,d,e,f = t
280 a,b,c,d,e,f = t
281 a,b,c,d,e,f = t
282
283 a,b,c = t[:3]
284 a,b,c = t[:3]
285 a,b,c = t[:3]
286 a,b,c = t[:3]
287 a,b,c = t[:3]
288 a,b,c = t[:3]
289
290 l = list(t)
291 t = tuple(l)
292
293 t = (1,2,3,4,5,6)
294
295 a,b,c,d,e,f = t
296 a,b,c,d,e,f = t
297 a,b,c,d,e,f = t
298
299 a,b,c = t[:3]
300 a,b,c = t[:3]
301 a,b,c = t[:3]
302 a,b,c = t[:3]
303 a,b,c = t[:3]
304 a,b,c = t[:3]
305
306 l = list(t)
307 t = tuple(l)
308
309 t = (1,2,3,4,5,6)
310
311 a,b,c,d,e,f = t
312 a,b,c,d,e,f = t
313 a,b,c,d,e,f = t
314
315 a,b,c = t[:3]
316 a,b,c = t[:3]
317 a,b,c = t[:3]
318 a,b,c = t[:3]
319 a,b,c = t[:3]
320 a,b,c = t[:3]
321
322 l = list(t)
323 t = tuple(l)
324
325 t = (1,2,3,4,5,6)
326
327 a,b,c,d,e,f = t
328 a,b,c,d,e,f = t
329 a,b,c,d,e,f = t
330
331 a,b,c = t[:3]
332 a,b,c = t[:3]
333 a,b,c = t[:3]
334 a,b,c = t[:3]
335 a,b,c = t[:3]
336 a,b,c = t[:3]
337
338 l = list(t)
339 t = tuple(l)
340
341 t = (1,2,3,4,5,6)
342
343 a,b,c,d,e,f = t
344 a,b,c,d,e,f = t
345 a,b,c,d,e,f = t
346
347 a,b,c = t[:3]
348 a,b,c = t[:3]
349 a,b,c = t[:3]
350 a,b,c = t[:3]
351 a,b,c = t[:3]
352 a,b,c = t[:3]
353
354 l = list(t)
355 t = tuple(l)
356
357 def calibrate(self):
358
Guido van Rossum805365e2007-05-07 22:24:25 +0000359 for i in range(self.rounds):
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000360 pass