浏览代码

Fix an off-by-1000 in time display in examples/ping.rs.

whitequark 7 年之前
父节点
当前提交
21ca116fd7
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      examples/ping.rs

+ 3 - 3
examples/ping.rs

@@ -118,10 +118,10 @@ fn main() {
 
                 if let Icmpv4Repr::EchoReply { seq_no, data, .. } = icmp_repr {
                     if let Some(_) = waiting_queue.get(&seq_no) {
-                        let packet_timestamp_us = NetworkEndian::read_i64(data);
-                        println!("{} bytes from {}: icmp_seq={}, time={:.3}ms",
+                        let packet_timestamp_ms = NetworkEndian::read_i64(data);
+                        println!("{} bytes from {}: icmp_seq={}, time={}ms",
                                  data.len(), remote_addr, seq_no,
-                                 (timestamp.total_millis() - packet_timestamp_us) as f64 / 1000.0);
+                                 timestamp.total_millis() - packet_timestamp_ms);
                         waiting_queue.remove(&seq_no);
                         received += 1;
                     }