@@ -291,31 +291,21 @@ fn get_search_config(generation: usize, kind: &str) -> SearchDrawConfig {
291
291
} ,
292
292
) ;
293
293
294
- // get average durations
295
- let durations = data
296
- . heuristic_state
297
- . states
298
- . get ( kind)
299
- // get a sum of all durations
300
- . map ( |best_state_idx| {
301
- get_search_statistics (
302
- & data. heuristic_state . search_states ,
303
- & names_rev,
304
- generation,
305
- |SearchResult ( _, _, ( _, to_state_idx) , _) | to_state_idx == best_state_idx,
306
- |acc : & mut Vec < ( usize , usize ) > , SearchResult ( name_idx, _, _, duration) | {
307
- let ( total, count) = ( acc[ * name_idx] . 0 , acc[ * name_idx] . 1 ) ;
308
- acc[ * name_idx] = ( total + * duration, count + 1 ) ;
309
- } ,
310
- )
311
- } )
312
- // calculate average
313
- . map ( |data| {
314
- data. into_iter ( )
315
- . map ( |( name, ( total, count) ) | ( name, total. checked_div ( count) . unwrap_or_default ( ) ) )
316
- . collect ( )
317
- } )
318
- . unwrap_or_default ( ) ;
294
+ // get duration averages for all states
295
+ let durations = get_search_statistics (
296
+ & data. heuristic_state . search_states ,
297
+ & names_rev,
298
+ generation,
299
+ |_| true ,
300
+ |acc : & mut Vec < ( usize , usize ) > , SearchResult ( name_idx, _, _, duration) | {
301
+ let ( total, count) = ( acc[ * name_idx] . 0 , acc[ * name_idx] . 1 ) ;
302
+ acc[ * name_idx] = ( total + * duration, count + 1 ) ;
303
+ } ,
304
+ )
305
+ // calculate average
306
+ . into_iter ( )
307
+ . map ( |( name, ( total, count) ) | ( name, total. checked_div ( count) . unwrap_or_default ( ) ) )
308
+ . collect ( ) ;
319
309
320
310
SearchDrawConfig { estimations, best, overall, durations }
321
311
} )
0 commit comments