@@ -576,28 +576,38 @@ fn get_latency(timeout: f64, no_progress: bool, json: bool) -> Result<i32, Outpu
576576 )
577577 . ok ( ) ;
578578 } else {
579- let score_table = result. iter ( ) . filter ( |x| x. 1 . is_ok ( ) ) . map ( |x| {
580- let time_delta = x. 1 . as_ref ( ) . unwrap ( ) ;
581- let hours = time_delta. num_hours ( ) ;
582- let latency = format_duration (
583- time_delta
584- . to_std ( )
585- . expect ( "Latency delta should not be < 0" ) ,
586- ) ;
579+ let mut score_table = result
580+ . iter ( )
581+ . filter_map ( |x| {
582+ if let Ok ( time_delta) = x. 1 {
583+ let hours = time_delta. num_hours ( ) ;
584+ let secs = time_delta. num_seconds ( ) ;
585+ let latency = format_duration (
586+ time_delta
587+ . to_std ( )
588+ . expect ( "Latency delta should not be < 0" ) ,
589+ ) ;
587590
588- let color_mirror_status = if hours <= 12 {
589- style ( latency) . green ( ) . to_string ( )
590- } else if hours <= 24 {
591- style ( latency) . yellow ( ) . to_string ( )
592- } else {
593- style ( latency) . red ( ) . to_string ( )
594- } ;
591+ let color_mirror_status = if hours <= 12 {
592+ style ( latency) . green ( ) . to_string ( )
593+ } else if hours <= 24 {
594+ style ( latency) . yellow ( ) . to_string ( )
595+ } else {
596+ style ( latency) . red ( ) . to_string ( )
597+ } ;
598+
599+ Some ( MirrorLatencyDisplay {
600+ name : x. 0 ,
601+ lanency : color_mirror_status,
602+ secs,
603+ } )
604+ } else {
605+ None
606+ }
607+ } )
608+ . collect :: < Vec < _ > > ( ) ;
595609
596- MirrorLatencyDisplay {
597- name : x. 0 ,
598- lanency : color_mirror_status,
599- }
600- } ) ;
610+ score_table. sort_unstable_by ( |a, b| a. secs . cmp ( & b. secs ) ) ;
601611
602612 let mut printer = PagerPrinter :: new ( stdout ( ) ) ;
603613
@@ -676,6 +686,8 @@ struct MirrorScoreDisplay<'a> {
676686struct MirrorLatencyDisplay < ' a > {
677687 name : & ' a str ,
678688 lanency : String ,
689+ #[ tabled( skip) ]
690+ secs : i64 ,
679691}
680692
681693fn speedtest (
0 commit comments