Skip to content

Commit 1d2604f

Browse files
committed
Measure dt from before connection init!
1 parent 5a537bb commit 1d2604f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

irpc-iroh/examples/0rtt.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ async fn ping_one_0rtt(
7474
node_id: NodeId,
7575
wait_for_ticket: bool,
7676
i: u64,
77+
t0: Instant,
7778
) -> Result<()> {
7879
let msg = i.to_be_bytes();
79-
let t0 = Instant::now();
8080
let data = api.echo_0rtt(msg.to_vec()).await?;
8181
let latency = endpoint.remote_info(node_id).and_then(|x| x.latency);
8282
if wait_for_ticket {
@@ -105,9 +105,9 @@ async fn ping_one_no_0rtt(
105105
endpoint: &Endpoint,
106106
node_id: NodeId,
107107
i: u64,
108+
t0: Instant,
108109
) -> Result<()> {
109110
let msg = i.to_be_bytes();
110-
let t0 = Instant::now();
111111
let data = api.echo(msg.to_vec()).await?;
112112
let latency = endpoint.remote_info(node_id).and_then(|x| x.latency);
113113
drop(api);
@@ -131,13 +131,14 @@ async fn ping_one(
131131
wait_for_ticket: bool,
132132
) -> Result<()> {
133133
let node_id = addr.node_id;
134+
let t0 = Instant::now();
134135
if !no_0rtt {
135136
println!("Connecting to {} with 0-RTT", addr.node_id);
136137
let api = EchoApi::connect_0rtt(endpoint.clone(), addr.clone()).await?;
137-
ping_one_0rtt(api, &endpoint, node_id, wait_for_ticket, i).await?;
138+
ping_one_0rtt(api, &endpoint, node_id, wait_for_ticket, i, t0).await?;
138139
} else {
139140
let api = EchoApi::connect(endpoint.clone(), addr.clone()).await?;
140-
ping_one_no_0rtt(api, &endpoint, node_id, i).await?;
141+
ping_one_no_0rtt(api, &endpoint, node_id, i, t0).await?;
141142
}
142143
Ok(())
143144
}

0 commit comments

Comments
 (0)