From 140329fa3ff74e57a5abadbdbc5dfdf9aa6f3f41 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 19 Nov 2020 16:00:18 +0000 Subject: [PATCH] Bug 27059: Add elapsed times to updatedatabase.pl --- installer/data/mysql/updatedatabase.pl | 32 ++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index b524fad3a6..841b20844e 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -23500,6 +23500,7 @@ sub SetVersion { C4::Context::clear_syspref_cache(); # invalidate cached preferences } +my $start_time = time; sub NewVersion { my ( $DBversion, $bug_number, $descriptions ) = @_; @@ -23509,27 +23510,48 @@ sub NewVersion { $descriptions = [ $descriptions ]; } my $first = 1; - my $time = POSIX::strftime("%H:%M:%S",localtime); + my ( $seconds, $time, $elapsed ) = get_timestrings(); for my $description ( @$descriptions ) { if ( @$descriptions > 1 ) { if ( $first ) { unless ( $bug_number ) { - say sprintf "Upgrade to %s done [%s]: %s", $DBversion, $time, $description; + say sprintf "Upgrade to %s done [%s %s]: %s", $DBversion, $time, $elapsed, $description; } else { - say sprintf "Upgrade to %s done [%s]: Bug %5s - %s", $DBversion, $time, $bug_number, $description; + say sprintf "Upgrade to %s done [%s %s]: Bug %5s - %s", $DBversion, $time, $elapsed, $bug_number, $description; } } else { say sprintf "\t\t\t\t\t\t - %s", $description; } } else { unless ( $bug_number ) { - say sprintf "Upgrade to %s done [%s]: %s", $DBversion, $time, $description; + say sprintf "Upgrade to %s done [%s %s]: %s", $DBversion, $time, $elapsed, $description; } else { - say sprintf "Upgrade to %s done [%s]: Bug %5s - %s", $DBversion, $time, $bug_number, $description; + say sprintf "Upgrade to %s done [%s %s]: Bug %5s - %s", $DBversion, $time, $elapsed, $bug_number, $description; } } $first = 0; } + $start_time = $seconds; +} + +sub get_timestrings { + use integer; + my $now = time; + my $elapsed = $now - $start_time; + local $_ = $elapsed; + my ( $d, $h, $m, $s ); + $s = $_ % 60; + $_ /= 60; + $m = $_ % 60; + $_ /= 60; + $h = $_ % 24; + $_ /= 24; + $d = $_; + + my $now_pretty = POSIX::strftime("%H:%M:%S",localtime($now)); + my $elapsed_pretty = $d ? "($d:$h:$m:$s)" : $h ? "($h:$m:$s)" : $m ? "($m:$s)" : "($s)"; + + return ( $now, $now_pretty, $elapsed_pretty); } =head2 CheckVersion -- 2.20.1