44
55use crate :: {
66 base_parsers:: { digits, string_to, till_newline, word} ,
7- time:: time_triple,
7+ time:: { StatsHeader , time_triple} ,
88 types:: { BrwStats , BrwStatsBucket } ,
99} ;
1010use combine:: {
@@ -120,17 +120,19 @@ where
120120 } )
121121}
122122
123- pub ( crate ) fn brw_stats < I > ( ) -> impl Parser < I , Output = Vec < BrwStats > >
123+ pub ( crate ) fn brw_stats < I > ( ) -> impl Parser < I , Output = ( StatsHeader , Vec < BrwStats > ) >
124124where
125125 I : Stream < Token = char > ,
126126 I :: Error : ParseError < I :: Token , I :: Range , I :: Position > ,
127127{
128- ( newline ( ) . with ( time_triple ( ) ) , spaces ( ) , many1 ( section ( ) ) ) . map ( |( _, _, y) | y)
128+ ( newline ( ) . with ( time_triple ( ) ) , spaces ( ) , many1 ( section ( ) ) )
129+ . map ( |( header, _, sections) | ( header, sections) )
129130}
130131
131132#[ cfg( test) ]
132133mod tests {
133134 use super :: * ;
135+ use crate :: time:: StatsHeader ;
134136 use insta:: assert_debug_snapshot;
135137
136138 #[ test]
@@ -307,48 +309,54 @@ pages per bulk r/w rpcs % cum % | rpcs % cum %
307309 assert_eq ! (
308310 result,
309311 Ok ( (
310- vec![
311- BrwStats {
312- name: "pages" . to_string( ) ,
313- unit: "rpcs" . to_string( ) ,
314- buckets: vec![ ] ,
312+ (
313+ StatsHeader {
314+ snapshot_time: "1534429278.185762481" . to_string( ) ,
315+ start_time: None ,
315316 } ,
316- BrwStats {
317- name: "discont_pages" . to_string( ) ,
318- unit: "rpcs" . to_string( ) ,
319- buckets: vec![ ] ,
320- } ,
321- BrwStats {
322- name: "discont_blocks" . to_string( ) ,
323- unit: "rpcs" . to_string( ) ,
324- buckets: vec![ ] ,
325- } ,
326- BrwStats {
327- name: "dio_frags" . to_string( ) ,
328- unit: "ios" . to_string( ) ,
329- buckets: vec![ ] ,
330- } ,
331- BrwStats {
332- name: "rpc_hist" . to_string( ) ,
333- unit: "ios" . to_string( ) ,
334- buckets: vec![ ] ,
335- } ,
336- BrwStats {
337- name: "io_time" . to_string( ) ,
338- unit: "ios" . to_string( ) ,
339- buckets: vec![ ] ,
340- } ,
341- BrwStats {
342- name: "disk_iosize" . to_string( ) ,
343- unit: "ios" . to_string( ) ,
344- buckets: vec![ ] ,
345- } ,
346- BrwStats {
347- name: "block_maps_msec" . to_string( ) ,
348- unit: "maps" . to_string( ) ,
349- buckets: vec![ ] ,
350- } ,
351- ] ,
317+ vec![
318+ BrwStats {
319+ name: "pages" . to_string( ) ,
320+ unit: "rpcs" . to_string( ) ,
321+ buckets: vec![ ] ,
322+ } ,
323+ BrwStats {
324+ name: "discont_pages" . to_string( ) ,
325+ unit: "rpcs" . to_string( ) ,
326+ buckets: vec![ ] ,
327+ } ,
328+ BrwStats {
329+ name: "discont_blocks" . to_string( ) ,
330+ unit: "rpcs" . to_string( ) ,
331+ buckets: vec![ ] ,
332+ } ,
333+ BrwStats {
334+ name: "dio_frags" . to_string( ) ,
335+ unit: "ios" . to_string( ) ,
336+ buckets: vec![ ] ,
337+ } ,
338+ BrwStats {
339+ name: "rpc_hist" . to_string( ) ,
340+ unit: "ios" . to_string( ) ,
341+ buckets: vec![ ] ,
342+ } ,
343+ BrwStats {
344+ name: "io_time" . to_string( ) ,
345+ unit: "ios" . to_string( ) ,
346+ buckets: vec![ ] ,
347+ } ,
348+ BrwStats {
349+ name: "disk_iosize" . to_string( ) ,
350+ unit: "ios" . to_string( ) ,
351+ buckets: vec![ ] ,
352+ } ,
353+ BrwStats {
354+ name: "block_maps_msec" . to_string( ) ,
355+ unit: "maps" . to_string( ) ,
356+ buckets: vec![ ] ,
357+ } ,
358+ ] ,
359+ ) ,
352360 ""
353361 ) )
354362 ) ;
@@ -358,7 +366,7 @@ pages per bulk r/w rpcs % cum % | rpcs % cum %
358366 fn test_brw_stats ( ) {
359367 let x = include_str ! ( "fixtures/brw_stats_with_data.txt" ) ;
360368
361- let result: ( Vec < _ > , _ ) = brw_stats ( ) . parse ( x) . unwrap ( ) ;
369+ let result = brw_stats ( ) . parse ( x) . unwrap ( ) ;
362370
363371 assert_debug_snapshot ! ( result) ;
364372 }
0 commit comments