From 91352884e4999cdaed6decfab72e8c33ee282eb5 Mon Sep 17 00:00:00 2001 From: Junichi Ito Date: Thu, 20 Jul 2023 20:45:27 +0900 Subject: [PATCH] Logging response MB and KB/s --- lib/copy_tuner_client/client.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/copy_tuner_client/client.rb b/lib/copy_tuner_client/client.rb index 4bc9ad2..0e6d842 100644 --- a/lib/copy_tuner_client/client.rb +++ b/lib/copy_tuner_client/client.rb @@ -54,7 +54,12 @@ def download response = http.request(request) t_ms = ((Time.now - t) * 1000).to_i if check response - log "Downloaded translations (#{t_ms}ms)" + bytesize = response.body.bytesize + kb = bytesize / 1024.0 + mb = kb / 1024.0 + t_s = t_ms / 1000.0 + kbs = kb / t_s + log "Downloaded translations (#{t_ms}ms, #{mb.round(1)}MB, #{kbs.round(1)}KB/s)" yield JSON.parse(response.body) else log "No new translations (#{t_ms}ms)"