diff options
| author | bors <bors@rust-lang.org> | 2013-07-23 22:46:39 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-07-23 22:46:39 -0700 |
| commit | 7f96eb58d2a4eed4651570ce719363008a8f269f (patch) | |
| tree | f674603e356b5ac6d4faa76fdaf5387ecd8cdace /src/libstd/num | |
| parent | af78e23006d9795bca32267a31e6f3cb9e73a6e1 (diff) | |
| parent | 978e5d94bc09a18cdfaa699508848bf8a39b46a9 (diff) | |
| download | rust-7f96eb58d2a4eed4651570ce719363008a8f269f.tar.gz rust-7f96eb58d2a4eed4651570ce719363008a8f269f.zip | |
auto merge of #7980 : graydon/rust/misc-benchmarks, r=catamorphism
Some machinery for enabling #[bench] benchmarks in std and some examples showing how to write them.
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/strconv.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 8e7f49464ff..722af828d5c 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -703,3 +703,27 @@ mod test { assert_eq!(n, None); } } + +#[cfg(test)] +mod bench { + use extra::test::BenchHarness; + use rand::{XorShiftRng,RngUtil}; + use uint; + use float; + + #[bench] + fn uint_to_str_rand(bh: &mut BenchHarness) { + let mut rng = XorShiftRng::new(); + do bh.iter { + uint::to_str(rng.gen()); + } + } + + #[bench] + fn float_to_str_rand(bh: &mut BenchHarness) { + let mut rng = XorShiftRng::new(); + do bh.iter { + float::to_str(rng.gen()); + } + } +} \ No newline at end of file |
