* [bug#50634] [PATCH] progress: Rate limit drawing in the progress-reporter/bar.
@ 2021-09-17 10:15 Christopher Baines
2021-09-30 21:05 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Baines @ 2021-09-17 10:15 UTC (permalink / raw)
To: 50634
This helps smooth the output in cases where the bar is updated very quickly,
for example in guix weather where it's computing derivations.
* guix/progress.scm (progress-reporter/bar): Wrap the drawing code with the
rate-limited procedure.
---
guix/progress.scm | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/guix/progress.scm b/guix/progress.scm
index 0cbc804ec1..4f8e98edc0 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -270,19 +270,25 @@ ABBREVIATION used to shorten FILE for display."
tasks is performed. Write PREFIX at the beginning of the line."
(define done 0)
+ (define (draw-bar)
+ (let* ((ratio (* 100. (/ done total))))
+ (erase-current-line port)
+ (if (string-null? prefix)
+ (display (progress-bar ratio (current-terminal-columns)) port)
+ (let ((width (- (current-terminal-columns)
+ (string-length prefix) 3)))
+ (display prefix port)
+ (display " " port)
+ (display (progress-bar ratio width) port)))
+ (force-output port)))
+
+ (define draw-bar/rate-limited
+ (rate-limited draw-bar %progress-interval))
+
(define (report-progress)
(set! done (+ 1 done))
(unless (> done total)
- (let* ((ratio (* 100. (/ done total))))
- (erase-current-line port)
- (if (string-null? prefix)
- (display (progress-bar ratio (current-terminal-columns)) port)
- (let ((width (- (current-terminal-columns)
- (string-length prefix) 3)))
- (display prefix port)
- (display " " port)
- (display (progress-bar ratio width) port)))
- (force-output port))))
+ (draw-bar/rate-limited)))
(progress-reporter
(start (lambda ()
--
2.33.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [bug#50634] [PATCH] progress: Rate limit drawing in the progress-reporter/bar.
2021-09-17 10:15 [bug#50634] [PATCH] progress: Rate limit drawing in the progress-reporter/bar Christopher Baines
@ 2021-09-30 21:05 ` Ludovic Courtès
2021-12-12 15:23 ` bug#50634: " Christopher Baines
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2021-09-30 21:05 UTC (permalink / raw)
To: Christopher Baines; +Cc: 50634
Hi Christopher,
Christopher Baines <mail@cbaines.net> skribis:
> This helps smooth the output in cases where the bar is updated very quickly,
> for example in guix weather where it's computing derivations.
>
> * guix/progress.scm (progress-reporter/bar): Wrap the drawing code with the
> rate-limited procedure.
I hit that problem quite frequently lately in shell-mode so I’m grateful
you fixed it. Go for it!
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#50634: [PATCH] progress: Rate limit drawing in the progress-reporter/bar.
2021-09-30 21:05 ` Ludovic Courtès
@ 2021-12-12 15:23 ` Christopher Baines
0 siblings, 0 replies; 3+ messages in thread
From: Christopher Baines @ 2021-12-12 15:23 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 50634-done
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> Hi Christopher,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> This helps smooth the output in cases where the bar is updated very quickly,
>> for example in guix weather where it's computing derivations.
>>
>> * guix/progress.scm (progress-reporter/bar): Wrap the drawing code with the
>> rate-limited procedure.
>
> I hit that problem quite frequently lately in shell-mode so I’m grateful
> you fixed it. Go for it!
I seemingly forgot about this, but I've now pushed this patch as
604880ae22e1a7662acb1d3f282242470de0cd03.
Thanks,
Chris
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-12 15:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 10:15 [bug#50634] [PATCH] progress: Rate limit drawing in the progress-reporter/bar Christopher Baines
2021-09-30 21:05 ` Ludovic Courtès
2021-12-12 15:23 ` bug#50634: " Christopher Baines
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).