幾つかのサイトにデータをPostして、レスポンスタイムに差があるかを調査する。
let now = time::Instant::now();
let mut post_url = format!("http://www.jsontest.com/");
let client = reqwest::Client::new();
let resp = client.post(post_url)
.header(reqwest::header::CONTENT_TYPE, "application/json")
.json(&str)
.send()
.await
.unwrap();
println!("{:?}", resp);
println!("{:?}", now.elapsed());
↓レスポンスタイムの差
同じサーバ内
67.997892ms
76.798063ms
73.945108ms
http://httpbin.org/post
626.023117ms
560.575466ms
1.050126063s
https://dummyjson.com/posts
695.071869ms
825.34323ms
676.196368ms
http://www.jsontest.com/
229.820077ms
256.854971ms
203.667686ms
当たり前だが、同じサーバ内のレスポンスは早い。
それ以外でも、サイトごとによって、レスポンスタイムが早いものと遅いものの違いが生じている。
なるほど、なかなか面白いね。