@@ -48,6 +48,14 @@ pub struct Opt {
48
48
49
49
#[ clap( long, action) ]
50
50
bw_limit_in_bytes : Option < usize > ,
51
+
52
+ /// Submit all zeroes instead of random data
53
+ #[ clap( long, action) ]
54
+ all_zeroes : bool ,
55
+
56
+ /// How long to wait before the auto flush check fires
57
+ #[ clap( long, action) ]
58
+ flush_timeout : Option < f32 > ,
51
59
}
52
60
53
61
pub fn opts ( ) -> Result < Opt > {
@@ -74,7 +82,7 @@ async fn main() -> Result<()> {
74
82
id : Uuid :: new_v4 ( ) ,
75
83
target : opt. target ,
76
84
lossy : false ,
77
- flush_timeout : None ,
85
+ flush_timeout : opt . flush_timeout ,
78
86
key : opt. key ,
79
87
cert_pem : opt. cert_pem ,
80
88
key_pem : opt. key_pem ,
@@ -128,28 +136,33 @@ async fn main() -> Result<()> {
128
136
1
129
137
} ;
130
138
131
- let write_buffers: Vec < Bytes > = ( 0 ..io_depth)
132
- . map ( |_| {
133
- Bytes :: from (
134
- ( 0 ..io_size)
135
- . map ( |_| rng. sample ( rand:: distributions:: Standard ) )
136
- . collect :: < Vec < u8 > > ( ) ,
137
- )
138
- } )
139
- . collect ( ) ;
140
-
141
139
let read_buffers: Vec < Buffer > =
142
140
( 0 ..io_depth) . map ( |_| Buffer :: new ( io_size) ) . collect ( ) ;
143
141
144
142
let mut io_operations_sent = 0 ;
145
143
let mut bw_consumed = 0 ;
146
- let mut io_operation_time = Instant :: now ( ) ;
144
+ let mut measurement_time = Instant :: now ( ) ;
145
+ let mut total_io_time = Duration :: ZERO ;
147
146
let mut iops: Vec < f32 > = vec ! [ ] ;
148
147
let mut bws: Vec < f32 > = vec ! [ ] ;
149
148
150
149
' outer: loop {
151
150
let mut futures = Vec :: with_capacity ( io_depth) ;
152
151
152
+ let write_buffers: Vec < Bytes > = ( 0 ..io_depth)
153
+ . map ( |_| {
154
+ Bytes :: from ( if opt. all_zeroes {
155
+ vec ! [ 0u8 ; io_size]
156
+ } else {
157
+ ( 0 ..io_size)
158
+ . map ( |_| rng. sample ( rand:: distributions:: Standard ) )
159
+ . collect :: < Vec < u8 > > ( )
160
+ } )
161
+ } )
162
+ . collect ( ) ;
163
+
164
+ let io_operation_time = Instant :: now ( ) ;
165
+
153
166
for i in 0 ..io_depth {
154
167
let offset: u64 =
155
168
rng. gen :: < u64 > ( ) % ( total_blocks - io_size as u64 / bsz) ;
@@ -173,15 +186,14 @@ async fn main() -> Result<()> {
173
186
174
187
crucible:: join_all ( futures) . await ?;
175
188
189
+ total_io_time += io_operation_time. elapsed ( ) ;
176
190
io_operations_sent +=
177
191
ceiling_div ! ( io_size * io_depth, 16 * 1024 * 1024 ) ;
178
192
bw_consumed += io_size * io_depth;
179
193
180
- let diff = io_operation_time. elapsed ( ) ;
181
-
182
- if diff > Duration :: from_secs ( 1 ) {
183
- let fractional_seconds: f32 =
184
- diff. as_secs ( ) as f32 + ( diff. subsec_nanos ( ) as f32 / 1e9 ) ;
194
+ if measurement_time. elapsed ( ) > Duration :: from_secs ( 1 ) {
195
+ let fractional_seconds: f32 = total_io_time. as_secs ( ) as f32
196
+ + ( total_io_time. subsec_nanos ( ) as f32 / 1e9 ) ;
185
197
186
198
iops. push ( io_operations_sent as f32 / fractional_seconds) ;
187
199
bws. push ( bw_consumed as f32 / fractional_seconds) ;
@@ -192,7 +204,8 @@ async fn main() -> Result<()> {
192
204
193
205
io_operations_sent = 0 ;
194
206
bw_consumed = 0 ;
195
- io_operation_time = Instant :: now ( ) ;
207
+ measurement_time = Instant :: now ( ) ;
208
+ total_io_time = Duration :: ZERO ;
196
209
}
197
210
}
198
211
0 commit comments