-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #66686 - Centril:rollup-07slyoo, r=Centril
Rollup of 5 pull requests Successful merges: - #64856 (Scope format! temporaries) - #66411 (mem::forget docs: mention ManuallyDrop) - #66594 (Fix cycle when debug-printing opaque types) - #66641 (parser: recover on nested ADTs as enum variants) - #66659 (make `./x.py bench` again) Failed merges: r? @ghost
- Loading branch information
Showing
14 changed files
with
315 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,63 @@ | ||
#![feature(slice_patterns)] | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
||
mod dispatch; | ||
mod pattern; | ||
use test::Bencher; | ||
|
||
// Static/dynamic method dispatch | ||
|
||
struct Struct { | ||
field: isize | ||
} | ||
|
||
trait Trait { | ||
fn method(&self) -> isize; | ||
} | ||
|
||
impl Trait for Struct { | ||
fn method(&self) -> isize { | ||
self.field | ||
} | ||
} | ||
|
||
#[bench] | ||
fn trait_vtable_method_call(b: &mut Bencher) { | ||
let s = Struct { field: 10 }; | ||
let t = &s as &dyn Trait; | ||
b.iter(|| { | ||
t.method() | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn trait_static_method_call(b: &mut Bencher) { | ||
let s = Struct { field: 10 }; | ||
b.iter(|| { | ||
s.method() | ||
}); | ||
} | ||
|
||
// Overhead of various match forms | ||
|
||
#[bench] | ||
fn option_some(b: &mut Bencher) { | ||
let x = Some(10); | ||
b.iter(|| { | ||
match x { | ||
Some(y) => y, | ||
None => 11 | ||
} | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn vec_pattern(b: &mut Bencher) { | ||
let x = [1,2,3,4,5,6]; | ||
b.iter(|| { | ||
match x { | ||
[1,2,3,..] => 10, | ||
_ => 11, | ||
} | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.