@@ -80,14 +80,12 @@ struct PerfRow {
8080
8181/// Creates an aggregation of perf_<KIND>_<NB_CPU>_<NB_OPS_PER_CPU> into corresponding perf_alone_<NB_CPU>_<NB_OPS_PER_CPU>.csv file
8282fn aggregate_perf ( raw_perf_results_file : PathBuf ) -> io:: Result < ( ) > {
83- debug ! ( "Processing perf file '{}'" , raw_perf_results_file. display( ) ) ;
8483
8584 let output_path = & format ! ( "{}.csv" , raw_perf_results_file. display( ) ) ;
8685 fs:: File :: create ( output_path) ?;
8786 let mut output_writer = csv:: Writer :: from_path ( output_path) ?;
8887
8988 if let Some ( ( nb_core, nb_ops_per_core) ) = parse_perf_metadata ( raw_perf_results_file. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ) {
90- debug ! ( "{} metadata : nb_core {} ; nb_ops_per_core {}" , raw_perf_results_file. display( ) , nb_core, nb_ops_per_core) ;
9189 let raw_perf_results_file = File :: open ( raw_perf_results_file) ?;
9290 let reader = BufReader :: new ( raw_perf_results_file) ;
9391 let mut iteration = 1 ;
@@ -159,16 +157,12 @@ fn parse_perf_metadata(file_name: &str) -> Option<(String, String)> {
159157
160158fn parse_hwpc_metadata ( dir_name : & str ) -> Option < ( i32 , i32 , usize ) > {
161159 if let Some ( dir_name) = Path :: new ( dir_name) . file_name ( ) . and_then ( |os_str| os_str. to_str ( ) ) {
162- debug ! ( "Filename to parse is : {}" , dir_name) ;
163160 let parts: Vec < & str > = dir_name. split ( '_' ) . collect ( ) ;
164161 if parts. len ( ) == 5 {
165- debug ! ( "Is hwpc alone" ) ;
166162 if let ( Ok ( nb_core) , Ok ( nb_ops_per_core) , Ok ( iteration) ) = ( parts[ 2 ] . parse :: < i32 > ( ) , parts[ 3 ] . parse :: < i32 > ( ) , parts[ 4 ] . parse :: < usize > ( ) ) {
167- debug ! ( "{:?}" , Some ( ( nb_core, nb_ops_per_core, iteration) ) ) ;
168163 return Some ( ( nb_core, nb_ops_per_core, iteration) ) ;
169164 }
170165 } else if parts. len ( ) == 6 {
171- debug ! ( "Is hwpc with perf" ) ;
172166 if let ( Ok ( nb_core) , Ok ( nb_ops_per_core) , Ok ( iteration) ) = ( parts[ 3 ] . parse :: < i32 > ( ) , parts[ 4 ] . parse :: < i32 > ( ) , parts[ 5 ] . parse :: < usize > ( ) ) {
173167 return Some ( ( nb_core, nb_ops_per_core, iteration) ) ;
174168 }
@@ -180,9 +174,16 @@ fn parse_hwpc_metadata(dir_name: &str) -> Option<(i32, i32, usize)> {
180174}
181175
182176fn aggregate_hwpc_file ( raw_rapl_file : & Path , output_path : & str , nb_core : i32 , nb_ops_per_core : i32 , iteration : usize ) -> io:: Result < ( ) > {
183- debug ! ( "Writing to hwpc aggregation file {:?}" , output_path) ;
184- let mut output_writer = csv:: Writer :: from_path ( output_path) ?;
185- debug ! ( "Processing hwpc raw file {:?}" , raw_rapl_file) ;
177+ let file_exists = std:: fs:: metadata ( output_path) . is_ok ( ) ;
178+ let file = std:: fs:: OpenOptions :: new ( )
179+ . write ( true )
180+ . create ( true )
181+ . append ( true )
182+ . open ( output_path) ?;
183+
184+ let mut output_writer = csv:: WriterBuilder :: new ( ) . has_headers ( !file_exists) . from_writer ( file) ;
185+
186+
186187 if let Ok ( mut reader) = csv:: Reader :: from_path ( raw_rapl_file) {
187188 let iter = reader. deserialize :: < HwpcRowRaw > ( ) ;
188189
@@ -207,7 +208,6 @@ fn aggregate_hwpc_file(raw_rapl_file: &Path, output_path: &str, nb_core: i32, nb
207208fn aggregate_hwpc_subdir ( subdir : & fs:: DirEntry , output_path : & str ) -> io:: Result < ( ) > {
208209
209210 let raw_rapl_file = subdir. path ( ) . join ( "rapl.csv" ) ;
210- debug ! ( "Processing hwpc aggregation file {:?}" , raw_rapl_file) ;
211211 if let Some ( ( nb_core, nb_ops_per_core, iteration) ) = parse_hwpc_metadata ( subdir. file_name ( ) . to_str ( ) . unwrap ( ) ) {
212212 aggregate_hwpc_file ( & raw_rapl_file, output_path, nb_core, nb_ops_per_core, iteration) ?;
213213 } else {
@@ -223,7 +223,6 @@ fn aggregate_hwpc(
223223
224224 let ( output_parent, output_basename) = ( raw_results_dir_path. parent ( ) . unwrap ( ) , raw_results_dir_path. file_name ( ) . unwrap ( ) ) ;
225225 let output_path = & format ! ( "{}/{}.csv" , output_parent. to_str( ) . unwrap( ) , output_basename. to_str( ) . unwrap( ) ) ;
226- debug ! ( "Output path : {}" , output_path) ;
227226
228227
229228 let mut raw_results_subdirs = Vec :: new ( ) ;
@@ -234,7 +233,6 @@ fn aggregate_hwpc(
234233 warn ! ( "Could not find subdirectories in {} directory" , output_parent. to_str( ) . unwrap( ) ) ;
235234 }
236235
237- debug ! ( "Found {:?} subdirs" , raw_results_subdirs) ;
238236 assert ! ( raw_results_subdirs. iter( ) . map( |subdir| aggregate_hwpc_subdir( subdir. as_ref( ) . unwrap( ) , output_path) ) . all( |result| result. is_ok( ) ) ) ;
239237
240238 Ok ( ( ) )
@@ -284,11 +282,9 @@ fn filter_perf_files(directory: &str) -> Vec<PathBuf> {
284282}
285283pub fn process_results ( results_directory : & str ) -> io:: Result < ( ) > {
286284 let perf_raw_files = filter_perf_files ( results_directory) ;
287- debug ! ( "Found perf files {:?} in {} directory" , perf_raw_files, results_directory) ;
288285 assert ! ( perf_raw_files. iter( ) . map( |perf_raw_file| aggregate_perf( perf_raw_file. to_path_buf( ) ) ) . all( |result| result. is_ok( ) ) ) ;
289286
290287 let hwpc_raw_dirs = filter_hwpc_dirs ( results_directory) ;
291- debug ! ( "Found hwpc subdirs {:?} in {} directory" , hwpc_raw_dirs, results_directory) ;
292288 assert ! ( hwpc_raw_dirs. iter( ) . map( |hwpc_raw_results_dir| aggregate_hwpc( hwpc_raw_results_dir. to_path_buf( ) ) ) . all( |result| result. is_ok( ) ) ) ;
293289
294290
0 commit comments