From 0b7f759511499bb61f2f8660017750a24027a2b5 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Thu, 19 Dec 2024 08:19:52 +0100 Subject: [PATCH] runner: display total runtime --- run | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/run b/run index 19f31ba..dee795e 100755 --- a/run +++ b/run @@ -6,12 +6,12 @@ use strict; use FindBin qw($Bin); use lib "$Bin/lib"; -use Time::HiRes qw(sleep); +use Time::HiRes qw(sleep time); use Linux::Inotify2; use POSIX qw(strftime WIFSIGNALED WTERMSIG SIGINT); use Mojo::File; -use Y::AoC qw(grey red); +use Y::AoC qw(grey red white); my $cmd = shift; die "Usage: $0 ./command.pl" if !defined $cmd || !-x $cmd; @@ -25,6 +25,7 @@ while (1) { my $b = "$backup-".strftime("%H-%M-%S", localtime(time)); $file->copy_to($b); $mtime = $file->stat->mtime; + my $starttime = time; say grey("\nrunning $cmd @ARGV... ============================"); system $cmd, @ARGV; if ($? && WIFSIGNALED($?) && WTERMSIG($?) == SIGINT) { @@ -37,7 +38,8 @@ while (1) { } else { my $line; $line .= (qw(. ' ~ - = _))[rand(5)] for 1 .. 30; - say grey("finished OK $line"); + say grey("finished OK $line after "), + white(sprintf('%.1f', time-$starttime), 's'); } my $inotify = Linux::Inotify2->new; -- 2.43.5