diff options
author | Christopher Baines <mail@cbaines.net> | 2020-05-09 19:02:27 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-05-09 19:02:27 +0100 |
commit | 79d1e86a4ca475d85d249c7e9b3a877e095e7101 (patch) | |
tree | b85496d9af91c8821eb2293613f8788156d06fff /guix-build-coordinator/agent-messaging/http.scm | |
parent | bb4dfcb9f1df274b12c7261bdcdcfb6f072caba3 (diff) | |
download | build-coordinator-79d1e86a4ca475d85d249c7e9b3a877e095e7101.tar build-coordinator-79d1e86a4ca475d85d249c7e9b3a877e095e7101.tar.gz |
Make it possible to see how fast outputs are transfered
Diffstat (limited to 'guix-build-coordinator/agent-messaging/http.scm')
-rw-r--r-- | guix-build-coordinator/agent-messaging/http.scm | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm index 7f275d8..959ac07 100644 --- a/guix-build-coordinator/agent-messaging/http.scm +++ b/guix-build-coordinator/agent-messaging/http.scm @@ -20,6 +20,7 @@ (define-module (guix-build-coordinator agent-messaging http) #:use-module (srfi srfi-11) + #:use-module (srfi srfi-19) #:use-module (ice-9 match) #:use-module (ice-9 format) #:use-module (ice-9 exceptions) @@ -346,12 +347,33 @@ port. Also, the port used can be changed by passing the --port option.\n" (lambda () (call-with-output-file output-file-name (lambda (output-port) - (let loop ((line (get-line body))) - (unless (eof-object? line) - (base64-decode line - base64-alphabet - output-port) - (loop (get-line body)))))) + (let ((start-time (current-time time-utc))) + (let loop ((line (get-line body)) + (base64-characters-read 0)) + (if (eof-object? line) + (let* ((end-time (current-time time-utc)) + (elapsed (time-difference end-time + start-time)) + (seconds-elapsed + (+ (time-second elapsed) + (/ (time-nanosecond elapsed) 1e9))) + (bytes-transfered + (* 3 (/ base64-characters-read 4)))) + (display + (simple-format + #f + "receiving ~A\n took ~A seconds\n bytes transfered: ~A\n speed (b/s): ~A\n" + output-file-name + seconds-elapsed + bytes-transfered + (/ bytes-transfered seconds-elapsed)))) + (begin + (base64-decode line + base64-alphabet + output-port) + (loop (get-line body) + (+ base64-characters-read + (string-length line))))))))) #t)) (no-content) (render-json |