File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,6 @@ documentation = "https://github.com/dtolnay/dtoa"
9
9
categories = [" value-formatting" ]
10
10
readme = " README.md"
11
11
exclude = [" performance.png" ]
12
+
13
+ [dev-dependencies ]
14
+ ryu = { path = " ../ryu" }
Original file line number Diff line number Diff line change @@ -38,6 +38,26 @@ macro_rules! benches {
38
38
}
39
39
) *
40
40
}
41
+
42
+ mod bench_ryu {
43
+ extern crate ryu;
44
+ use test:: { Bencher , black_box} ;
45
+ $(
46
+ #[ bench]
47
+ fn $name( b: & mut Bencher ) {
48
+ use std:: io:: Write ;
49
+
50
+ let mut buf = Vec :: with_capacity( 20 ) ;
51
+
52
+ b. iter( || {
53
+ buf. clear( ) ;
54
+ let mut bytes = [ 0u8 ; 24 ] ;
55
+ let n = unsafe { ryu:: d2s_buffered_n( black_box( $value) , & mut bytes[ 0 ] ) } ;
56
+ buf. write_all( & bytes[ ..n] ) . unwrap( ) ;
57
+ } ) ;
58
+ }
59
+ ) *
60
+ }
41
61
}
42
62
}
43
63
@@ -47,8 +67,10 @@ benches!(
47
67
bench_e_f64( 2.718281828459045f64 ) ,
48
68
bench_max_f64( :: std:: f64 :: MAX ) ,
49
69
70
+ /*
50
71
bench_0_f32(0f32),
51
72
bench_short_f32(0.1234f32),
52
73
bench_e_f32(2.718281828459045f32),
53
74
bench_max_f32(::std::f32::MAX),
75
+ */
54
76
) ;
You can’t perform that action at this time.
0 commit comments