diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2014-01-18 19:25:38 +0100 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2014-01-18 20:16:30 +0100 |
| commit | aaf8ba7c51011570e7a6bb350345c23378c4152c (patch) | |
| tree | d7904a66a2ad4fed5741f477f416d8a37d7ee358 /src/libstd/num/mod.rs | |
| parent | 2952685917cb17a3d849cb02d17ce71ccecfb855 (diff) | |
| download | rust-aaf8ba7c51011570e7a6bb350345c23378c4152c.tar.gz rust-aaf8ba7c51011570e7a6bb350345c23378c4152c.zip | |
Added benchmark for pow and pow_with_uint
Diffstat (limited to 'src/libstd/num/mod.rs')
| -rw-r--r-- | src/libstd/num/mod.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index bdbf0344b47..db1c227466b 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -1684,3 +1684,24 @@ mod tests { assert_pow(2u64, 50); } } + + +#[cfg(test)] +mod bench { + use num; + use vec; + use prelude::*; + use extra::test::BenchHarness; + + #[bench] + fn bench_pow_function(b: &mut BenchHarness) { + let v = vec::from_fn(1024, |n| n); + b.iter(|| {v.iter().fold(0, |old, new| num::pow(old, *new));}); + } + + #[bench] + fn bench_pow_with_uint_function(b: &mut BenchHarness) { + let v = vec::from_fn(1024, |n| n); + b.iter(|| {v.iter().fold(0, |old, new| num::pow_with_uint(old, *new));}); + } +} |
