Added benchmark for pow and pow_with_uint
This commit is contained in:
parent
2952685917
commit
aaf8ba7c51
1 changed files with 21 additions and 0 deletions
|
@ -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));});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue