File tree Expand file tree Collapse file tree 2 files changed +66
-1
lines changed Expand file tree Collapse file tree 2 files changed +66
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
14
14
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
15
15
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
16
16
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17
- refs/heads/auto: ca5ed4cc498ad5da22c6e1c4c0b79df07a07029e
17
+ refs/heads/auto: d9c0634536c8ac6cd6309221b1bbd93517686aba
18
18
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
19
19
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
Original file line number Diff line number Diff line change @@ -195,3 +195,68 @@ mod tests {
195
195
unsafe { assert_eq ! ( did_run, true ) ; }
196
196
}
197
197
}
198
+
199
+ /// Completely miscellaneous language-construct benchmarks.
200
+ #[ cfg( test) ]
201
+ mod bench {
202
+
203
+ use extra:: test:: BenchHarness ;
204
+ use option:: { Some , None } ;
205
+
206
+ // Static/dynamic method dispatch
207
+
208
+ struct Struct {
209
+ field : int
210
+ }
211
+
212
+ trait Trait {
213
+ fn method ( & self ) -> int ;
214
+ }
215
+
216
+ impl Trait for Struct {
217
+ fn method ( & self ) -> int {
218
+ self . field
219
+ }
220
+ }
221
+
222
+ #[ bench]
223
+ fn trait_vtable_method_call ( bh : & mut BenchHarness ) {
224
+ let s = Struct { field : 10 } ;
225
+ let t = & s as & Trait ;
226
+ do bh. iter {
227
+ t. method ( ) ;
228
+ }
229
+ }
230
+
231
+ #[ bench]
232
+ fn trait_static_method_call ( bh : & mut BenchHarness ) {
233
+ let s = Struct { field : 10 } ;
234
+ do bh. iter {
235
+ s. method ( ) ;
236
+ }
237
+ }
238
+
239
+ // Overhead of various match forms
240
+
241
+ #[ bench]
242
+ fn match_option_some ( bh : & mut BenchHarness ) {
243
+ let x = Some ( 10 ) ;
244
+ do bh. iter {
245
+ let _q = match x {
246
+ Some ( y) => y,
247
+ None => 11
248
+ } ;
249
+ }
250
+ }
251
+
252
+ #[ bench]
253
+ fn match_vec_pattern ( bh : & mut BenchHarness ) {
254
+ let x = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
255
+ do bh. iter {
256
+ let _q = match x {
257
+ [ 1 , 2 , 3 , .._] => 10 ,
258
+ _ => 11
259
+ } ;
260
+ }
261
+ }
262
+ }
You can’t perform that action at this time.
0 commit comments