]> git.lizzy.rs Git - rust.git/blob - src/libcore/bench/num/dec2flt/mod.rs
Unignore u128 test for stage 0,1
[rust.git] / src / libcore / bench / num / dec2flt / mod.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use std::f64;
12 use test::Bencher;
13
14 #[bench]
15 fn bench_0(b: &mut Bencher) {
16     b.iter(|| "0.0".parse::<f64>());
17 }
18
19 #[bench]
20 fn bench_42(b: &mut Bencher) {
21     b.iter(|| "42".parse::<f64>());
22 }
23
24 #[bench]
25 fn bench_huge_int(b: &mut Bencher) {
26     // 2^128 - 1
27     b.iter(|| "170141183460469231731687303715884105727".parse::<f64>());
28 }
29
30 #[bench]
31 fn bench_short_decimal(b: &mut Bencher) {
32     b.iter(|| "1234.5678".parse::<f64>());
33 }
34
35 #[bench]
36 fn bench_pi_long(b: &mut Bencher) {
37     b.iter(|| "3.14159265358979323846264338327950288".parse::<f64>());
38 }
39
40 #[bench]
41 fn bench_pi_short(b: &mut Bencher) {
42     b.iter(|| "3.141592653589793".parse::<f64>())
43 }
44
45 #[bench]
46 fn bench_1e150(b: &mut Bencher) {
47     b.iter(|| "1e150".parse::<f64>());
48 }
49
50 #[bench]
51 fn bench_long_decimal_and_exp(b: &mut Bencher) {
52     b.iter(|| "727501488517303786137132964064381141071e-123".parse::<f64>());
53 }
54
55 #[bench]
56 fn bench_min_subnormal(b: &mut Bencher) {
57     b.iter(|| "5e-324".parse::<f64>());
58 }
59
60 #[bench]
61 fn bench_min_normal(b: &mut Bencher) {
62     b.iter(|| "2.2250738585072014e-308".parse::<f64>());
63 }
64
65 #[bench]
66 fn bench_max(b: &mut Bencher) {
67     b.iter(|| "1.7976931348623157e308".parse::<f64>());
68 }