File tree 5 files changed +63
-65
lines changed
librustc_codegen_ssa/back/rpath
5 files changed +63
-65
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ macro_rules! from_str_bench {
35
35
. iter( )
36
36
. cycle( )
37
37
. take( 5_000 )
38
- . filter_map( |s| <( $t ) >:: from_str( s) . ok( ) )
38
+ . filter_map( |s| <$t >:: from_str( s) . ok( ) )
39
39
. max( )
40
40
} )
41
41
}
@@ -51,7 +51,7 @@ macro_rules! from_str_radix_bench {
51
51
. iter( )
52
52
. cycle( )
53
53
. take( 5_000 )
54
- . filter_map( |s| <( $t ) >:: from_str_radix( s, $radix) . ok( ) )
54
+ . filter_map( |s| <$t >:: from_str_radix( s, $radix) . ok( ) )
55
55
. max( )
56
56
} )
57
57
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ #![ feature( slice_patterns) ]
1
2
#![ feature( test) ]
2
3
3
4
extern crate test;
4
5
5
- mod dispatch;
6
- mod pattern;
6
+ use test:: Bencher ;
7
+
8
+ // Static/dynamic method dispatch
9
+
10
+ struct Struct {
11
+ field : isize
12
+ }
13
+
14
+ trait Trait {
15
+ fn method ( & self ) -> isize ;
16
+ }
17
+
18
+ impl Trait for Struct {
19
+ fn method ( & self ) -> isize {
20
+ self . field
21
+ }
22
+ }
23
+
24
+ #[ bench]
25
+ fn trait_vtable_method_call ( b : & mut Bencher ) {
26
+ let s = Struct { field : 10 } ;
27
+ let t = & s as & dyn Trait ;
28
+ b. iter ( || {
29
+ t. method ( )
30
+ } ) ;
31
+ }
32
+
33
+ #[ bench]
34
+ fn trait_static_method_call ( b : & mut Bencher ) {
35
+ let s = Struct { field : 10 } ;
36
+ b. iter ( || {
37
+ s. method ( )
38
+ } ) ;
39
+ }
40
+
41
+ // Overhead of various match forms
42
+
43
+ #[ bench]
44
+ fn option_some ( b : & mut Bencher ) {
45
+ let x = Some ( 10 ) ;
46
+ b. iter ( || {
47
+ match x {
48
+ Some ( y) => y,
49
+ None => 11
50
+ }
51
+ } ) ;
52
+ }
53
+
54
+ #[ bench]
55
+ fn vec_pattern ( b : & mut Bencher ) {
56
+ let x = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
57
+ b. iter ( || {
58
+ match x {
59
+ [ 1 , 2 , 3 , ..] => 10 ,
60
+ _ => 11 ,
61
+ }
62
+ } ) ;
63
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ fn test_minimize2() {
52
52
fn test_rpath_relative ( ) {
53
53
if cfg ! ( target_os = "macos" ) {
54
54
let config = & mut RPathConfig {
55
- used_crates : Vec :: new ( ) ,
55
+ used_crates : & [ ] ,
56
56
has_rpath : true ,
57
57
is_like_osx : true ,
58
58
linker_is_gnu : false ,
@@ -64,7 +64,7 @@ fn test_rpath_relative() {
64
64
assert_eq ! ( res, "@loader_path/../lib" ) ;
65
65
} else {
66
66
let config = & mut RPathConfig {
67
- used_crates : Vec :: new ( ) ,
67
+ used_crates : & [ ] ,
68
68
out_filename : PathBuf :: from ( "bin/rustc" ) ,
69
69
get_install_prefix_lib_path : & mut || panic ! ( ) ,
70
70
has_rpath : true ,
You can’t perform that action at this time.
0 commit comments