From f156c432e0d387ffe68f2e10ba8eb31c5c0a6a27 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 21 Apr 2021 16:20:49 +0200 Subject: [PATCH] Fix stop watch --- Scripts/build-repo.ps1 | 3 ++- Scripts/build-repos.ps1 | 3 ++- Scripts/check-dns-resolution.ps1 | 8 ++++---- Scripts/clone-repos.ps1 | 3 ++- Scripts/fetch-repos.ps1 | 3 ++- Scripts/pull-repos.ps1 | 3 ++- Scripts/upload-file.ps1 | 3 ++- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Scripts/build-repo.ps1 b/Scripts/build-repo.ps1 index c543012a..6bf6c7ab 100755 --- a/Scripts/build-repo.ps1 +++ b/Scripts/build-repo.ps1 @@ -78,7 +78,8 @@ try { exit 0 } - "✔️ built Git repository 📂$RepoDir in $($StopWatch.Elapsed.Seconds) sec." + [int]$Elapsed = $StopWatch.TotalSeconds + "✔️ built Git repository 📂$RepoDir in $Elapsed sec." exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/build-repos.ps1 b/Scripts/build-repos.ps1 index c5eec932..42b6657a 100755 --- a/Scripts/build-repos.ps1 +++ b/Scripts/build-repos.ps1 @@ -20,7 +20,8 @@ try { $Count++ } - write-host -foregroundColor green "✔️ $Count Git repositories built at $ParentDir in $($StopWatch.Elapsed.Seconds) second(s)" + [int]$Elapsed = $StopWatch.TotalSeconds + write-host -foregroundColor green "✔️ built $Count Git repositories at $ParentDir in $Elapsed sec." exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/check-dns-resolution.ps1 b/Scripts/check-dns-resolution.ps1 index 723e60d3..aa6d0c37 100755 --- a/Scripts/check-dns-resolution.ps1 +++ b/Scripts/check-dns-resolution.ps1 @@ -7,8 +7,8 @@ #> try { - write-progress "Reading Data/domain-names.csv..." $StopWatch = [system.diagnostics.stopwatch]::startNew() + write-progress "Reading Data/domain-names.csv..." $PathToRepo = "$PSScriptRoot/.." $Table = import-csv "$PathToRepo/Data/domain-names.csv" @@ -23,9 +23,9 @@ try { } $Count = $Table.Length - $Elapsed = $StopWatch.Elapsed - $Average = [math]::round($Count / $Elapsed.Seconds, 1) - "✔️ $Average domains/s ($Count domains resolved in $($Elapsed.Seconds) seconds)" + [int]$Elapsed = $StopWatch.TotalSeconds + $Average = [math]::round($Count / $Elapsed, 1) + "✔️ $Average domains/s ($Count domains resolved in $Elapsed sec.)" exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/clone-repos.ps1 b/Scripts/clone-repos.ps1 index 40fb9497..a338b443 100755 --- a/Scripts/clone-repos.ps1 +++ b/Scripts/clone-repos.ps1 @@ -31,7 +31,8 @@ try { if ($lastExitCode -ne "0") { throw "'git clone $URL' failed" } $Count++ } - "✔️ cloned $Count Git repositories at 📂$ParentDir in $($StopWatch.Elapsed.Seconds) sec." + [int]$Elapsed = $StopWatch.TotalSeconds + "✔️ cloned $Count Git repositories at 📂$ParentDir in $Elapsed sec." exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/fetch-repos.ps1 b/Scripts/fetch-repos.ps1 index 738fa221..5956c09d 100755 --- a/Scripts/fetch-repos.ps1 +++ b/Scripts/fetch-repos.ps1 @@ -28,7 +28,8 @@ try { $Count++ } - "✔️ updated $Count Git repositories at 📂$ParentDir in $($StopWatch.Elapsed.Seconds) sec." + [int]$Elapsed = $StopWatch.TotalSeconds + "✔️ updated $Count Git repositories at 📂$ParentDir in $Elapsed sec." exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/pull-repos.ps1 b/Scripts/pull-repos.ps1 index 10efd0f9..b8b3bfac 100755 --- a/Scripts/pull-repos.ps1 +++ b/Scripts/pull-repos.ps1 @@ -30,7 +30,8 @@ try { $Count++ } - "✔️ updated $Count Git repositories at 📂$ParentDir in $($StopWatch.Elapsed.Seconds) sec." + [int]$Elapsed = $StopWatch.TotalSeconds + "✔️ updated $Count Git repositories at 📂$ParentDir in $Elapsed sec." exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/upload-file.ps1 b/Scripts/upload-file.ps1 index 61e21760..4a8af4c3 100644 --- a/Scripts/upload-file.ps1 +++ b/Scripts/upload-file.ps1 @@ -46,7 +46,8 @@ try { $ftpStream.Dispose() $fileStream.Dispose() - write-host -foregroundColor green "✔️ uploaded $File to $URL in $($StopWatch.Elapsed.Seconds) second(s)" + [int]$Elapsed = $StopWatch.TotalSeconds + "✔️ uploaded $File to $URL in $Elapsed sec." exit 0 } catch { write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"