Skip to content

Commit e99ebb6

Browse files
committed
Send and receive times in non-JSON summaries are now the number of seconds for the longest associated stream
1 parent b96d405 commit e99ebb6

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/protocol/results.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,8 @@ impl TestResults for TcpTestResults {
795795

796796
fn to_string(&self, bit:bool, omit_seconds:usize) -> String {
797797
let stream_count = self.stream_results.len();
798+
let mut stream_send_durations = vec![0.0; stream_count];
799+
let mut stream_receive_durations = vec![0.0; stream_count];
798800

799801
let mut duration_send:f64 = 0.0;
800802
let mut bytes_sent:u64 = 0;
@@ -803,13 +805,15 @@ impl TestResults for TcpTestResults {
803805
let mut bytes_received:u64 = 0;
804806

805807

806-
for stream in self.stream_results.values() {
808+
for (stream_idx, stream) in self.stream_results.values().enumerate() {
807809
for (i, sr) in stream.send_results.iter().enumerate() {
808810
if i < omit_seconds {
809811
continue;
810812
}
811813

812814
duration_send += sr.duration as f64;
815+
stream_send_durations[stream_idx] += sr.duration as f64;
816+
813817
bytes_sent += sr.bytes_sent;
814818
}
815819

@@ -819,9 +823,13 @@ impl TestResults for TcpTestResults {
819823
}
820824

821825
duration_receive += rr.duration as f64;
826+
stream_receive_durations[stream_idx] += rr.duration as f64;
827+
822828
bytes_received += rr.bytes_received;
823829
}
824830
}
831+
stream_send_durations.sort_by(|a, b| a.partial_cmp(b).unwrap());
832+
stream_receive_durations.sort_by(|a, b| a.partial_cmp(b).unwrap());
825833

826834
let send_duration_divisor;
827835
if duration_send == 0.0 { //avoid zerodiv, which can happen if all streams fail
@@ -863,11 +871,11 @@ impl TestResults for TcpTestResults {
863871
TCP receive result over {:.2}s | streams: {}\n\
864872
stream-average bytes per second: {:.3} | {}\n\
865873
total bytes: {} | per second: {:.3} | {}",
866-
duration_send, stream_count,
874+
stream_send_durations[stream_send_durations.len() - 1], stream_count,
867875
send_bytes_per_second, send_throughput,
868876
bytes_sent, send_bytes_per_second * stream_count as f64, total_send_throughput,
869877

870-
duration_receive, stream_count,
878+
stream_receive_durations[stream_receive_durations.len() - 1], stream_count,
871879
receive_bytes_per_second, receive_throughput,
872880
bytes_received, receive_bytes_per_second * stream_count as f64, total_receive_throughput,
873881
);
@@ -1049,6 +1057,8 @@ impl TestResults for UdpTestResults {
10491057

10501058
fn to_string(&self, bit:bool, omit_seconds:usize) -> String {
10511059
let stream_count = self.stream_results.len();
1060+
let mut stream_send_durations = vec![0.0; stream_count];
1061+
let mut stream_receive_durations = vec![0.0; stream_count];
10521062

10531063
let mut duration_send:f64 = 0.0;
10541064

@@ -1068,13 +1078,14 @@ impl TestResults for UdpTestResults {
10681078
let mut jitter_weight:f64 = 0.0;
10691079

10701080

1071-
for stream in self.stream_results.values() {
1081+
for (stream_idx, stream) in self.stream_results.values().enumerate() {
10721082
for (i, sr) in stream.send_results.iter().enumerate() {
10731083
if i < omit_seconds {
10741084
continue;
10751085
}
10761086

10771087
duration_send += sr.duration as f64;
1088+
stream_send_durations[stream_idx] += sr.duration as f64;
10781089

10791090
bytes_sent += sr.bytes_sent;
10801091
packets_sent += sr.packets_sent;
@@ -1086,6 +1097,7 @@ impl TestResults for UdpTestResults {
10861097
}
10871098

10881099
duration_receive += rr.duration as f64;
1100+
stream_receive_durations[stream_idx] += rr.duration as f64;
10891101

10901102
bytes_received += rr.bytes_received;
10911103
packets_received += rr.packets_received;
@@ -1100,6 +1112,8 @@ impl TestResults for UdpTestResults {
11001112
}
11011113
}
11021114
}
1115+
stream_send_durations.sort_by(|a, b| a.partial_cmp(b).unwrap());
1116+
stream_receive_durations.sort_by(|a, b| a.partial_cmp(b).unwrap());
11031117

11041118
let send_duration_divisor;
11051119
if duration_send == 0.0 { //avoid zerodiv, which can happen if all streams fail
@@ -1150,12 +1164,12 @@ impl TestResults for UdpTestResults {
11501164
stream-average bytes per second: {:.3} | {}\n\
11511165
total bytes: {} | per second: {:.3} | {}\n\
11521166
packets: {} | lost: {} ({:.1}%) | out-of-order: {} | duplicate: {} | per second: {:.3}",
1153-
duration_send, stream_count,
1167+
stream_send_durations[stream_send_durations.len() - 1], stream_count,
11541168
send_bytes_per_second, send_throughput,
11551169
bytes_sent, send_bytes_per_second * stream_count as f64, total_send_throughput,
11561170
packets_sent, (packets_sent as f64 / send_duration_divisor) * stream_count as f64,
11571171

1158-
duration_receive, stream_count,
1172+
stream_receive_durations[stream_receive_durations.len() - 1], stream_count,
11591173
receive_bytes_per_second, receive_throughput,
11601174
bytes_received, receive_bytes_per_second * stream_count as f64, total_receive_throughput,
11611175
packets_received, packets_lost, (packets_lost as f64 / packets_sent_divisor) * 100.0, packets_out_of_order, packets_duplicated, (packets_received as f64 / receive_duration_divisor) * stream_count as f64,

0 commit comments

Comments
 (0)