-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
64 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,53 @@ | ||
#![feature(test)] | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
extern crate test; | ||
use test::Bencher; | ||
|
||
extern crate clear_on_drop; | ||
use clear_on_drop::ClearOnDrop; | ||
|
||
#[bench] | ||
fn clear_on_drop_small(b: &mut Bencher) { | ||
fn clear_on_drop_small(c: &mut Criterion) { | ||
#[derive(Default)] | ||
struct Data { | ||
_data: u64, | ||
} | ||
|
||
let mut place = Data::default(); | ||
b.iter(|| { ClearOnDrop::new(&mut place); }) | ||
c.bench_function("clear_on_drop_small", |b| { | ||
b.iter(|| { | ||
ClearOnDrop::new(&mut place); | ||
}) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn clear_on_drop_medium(b: &mut Bencher) { | ||
fn clear_on_drop_medium(c: &mut Criterion) { | ||
#[derive(Default)] | ||
struct Data { | ||
_data: [u64; 32], | ||
} | ||
|
||
let mut place = Data::default(); | ||
b.iter(|| { ClearOnDrop::new(&mut place); }) | ||
c.bench_function("clear_on_drop_medium", |b| { | ||
b.iter(|| { | ||
ClearOnDrop::new(&mut place); | ||
}) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn clear_on_drop_large(b: &mut Bencher) { | ||
fn clear_on_drop_large(c: &mut Criterion) { | ||
#[derive(Default)] | ||
struct Data { | ||
_data: [[u64; 32]; 32], | ||
} | ||
|
||
let mut place = Data::default(); | ||
b.iter(|| { ClearOnDrop::new(&mut place); }) | ||
c.bench_function("clear_on_drop_large", |b| { | ||
b.iter(|| { | ||
ClearOnDrop::new(&mut place); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches, | ||
clear_on_drop_small, | ||
clear_on_drop_medium, | ||
clear_on_drop_large | ||
); | ||
criterion_main!(benches); |
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,27 +1,36 @@ | ||
#![feature(test)] | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
extern crate test; | ||
use test::Bencher; | ||
|
||
extern crate clear_on_drop; | ||
use clear_on_drop::{clear_stack_on_return, clear_stack_on_return_fnonce}; | ||
|
||
#[bench] | ||
fn clear_stack_on_return_tiny(b: &mut Bencher) { | ||
b.iter(|| clear_stack_on_return(1, || 0x41)) | ||
fn clear_stack_on_return_tiny(c: &mut Criterion) { | ||
c.bench_function("clear_stack_on_return_tiny", |b| { | ||
b.iter(|| clear_stack_on_return(1, || 0x41)) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn clear_stack_on_return_small(b: &mut Bencher) { | ||
b.iter(|| clear_stack_on_return(2, || 0x41)) | ||
fn clear_stack_on_return_small(c: &mut Criterion) { | ||
c.bench_function("clear_stack_on_return_small", |b| { | ||
b.iter(|| clear_stack_on_return(2, || 0x41)) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn clear_stack_on_return_fnonce_tiny(b: &mut Bencher) { | ||
b.iter(|| clear_stack_on_return_fnonce(1, || 0x41)) | ||
fn clear_stack_on_return_fnonce_tiny(c: &mut Criterion) { | ||
c.bench_function("clear_stack_on_return_fnonce_tiny", |b| { | ||
b.iter(|| clear_stack_on_return_fnonce(1, || 0x41)) | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn clear_stack_on_return_fnonce_small(b: &mut Bencher) { | ||
b.iter(|| clear_stack_on_return_fnonce(2, || 0x41)) | ||
fn clear_stack_on_return_fnonce_small(c: &mut Criterion) { | ||
c.bench_function("clear_stack_on_return_fnonce_small", |b| { | ||
b.iter(|| clear_stack_on_return_fnonce(2, || 0x41)) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches, | ||
clear_stack_on_return_tiny, | ||
clear_stack_on_return_small, | ||
clear_stack_on_return_fnonce_tiny, | ||
clear_stack_on_return_fnonce_small | ||
); | ||
criterion_main!(benches); |
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,5 +1,3 @@ | ||
extern crate cc; | ||
|
||
fn main() { | ||
if !cfg!(feature = "no_cc") { | ||
cc::Build::new() | ||
|
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