mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-23 23:29:02 +01:00
Improve the time measurement
This commit is contained in:
parent
edb2bc56e6
commit
2b7b6fdf1a
@ -9,7 +9,8 @@
|
||||
param($RepoDir = "$PWD")
|
||||
|
||||
try {
|
||||
$StartTime = get-date
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if (test-path "$RepoDir/CMakeLists.txt") {
|
||||
"Building $RepoDir using CMakeLists.txt..."
|
||||
if (-not(test-path "$RepoDir/CMakeBuild")) {
|
||||
@ -71,8 +72,8 @@ try {
|
||||
write-warning "Sorry, no clue how to build $RepoDir"
|
||||
exit 0
|
||||
}
|
||||
$Elapsed = new-timeSpan -start $StartTime -end (get-date)
|
||||
write-host -foregroundColor green "OK - built Git repository $RepoDir in $($Elapsed.seconds) second(s)"
|
||||
|
||||
write-host -foregroundColor green "OK - built Git repository $RepoDir in $($StopWatch.Elapsed.Seconds) second(s)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -10,7 +10,7 @@ param($ParentDir = "$PWD")
|
||||
|
||||
try {
|
||||
"Building Git repositories under $($ParentDir)..."
|
||||
$StartTime = get-date
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||
set-location $ParentDir
|
||||
@ -21,8 +21,7 @@ try {
|
||||
$Count++
|
||||
}
|
||||
|
||||
$Elapsed = new-timeSpan -start $StartTime -end (get-date)
|
||||
write-host -foregroundColor green "OK - built $Count Git repositories under $ParentDir in $($Elapsed.seconds) second(s)"
|
||||
write-host -foregroundColor green "OK - built $Count Git repositories under $ParentDir in $($StopWatch.Elapsed.Seconds) second(s)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -7,9 +7,9 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$StartTime = get-date
|
||||
|
||||
write-progress "Reading Data/domain-names.csv..."
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
$PathToRepo = "$PSScriptRoot/.."
|
||||
$Table = import-csv "$PathToRepo/Data/domain-names.csv"
|
||||
|
||||
@ -23,9 +23,9 @@ try {
|
||||
}
|
||||
$Count = $Table.Length
|
||||
|
||||
$Elapsed = New-Timespan -start $StartTime -end (get-date)
|
||||
$Average = [math]::round($Count / $Elapsed.seconds, 1)
|
||||
write-host -foregroundColor green "OK - $Average domains/s ($Count domains resolved in $($Elapsed.seconds) seconds)"
|
||||
$Elapsed = $StopWatch.Elapsed
|
||||
$Average = [math]::round($Count / $Elapsed.Seconds, 1)
|
||||
write-host -foregroundColor green "OK - $Average domains/s ($Count domains resolved in $($Elapsed.Seconds) seconds)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -10,7 +10,7 @@ param($ParentDir = "$PWD")
|
||||
|
||||
try {
|
||||
"Fetching updates for Git repositories under $($ParentDir)..."
|
||||
$StartTime = get-date
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||
set-location $ParentDir
|
||||
@ -30,8 +30,7 @@ try {
|
||||
$Count++
|
||||
}
|
||||
|
||||
$Elapsed = new-timeSpan -start $StartTime -end (get-date)
|
||||
write-host -foregroundColor green "OK - fetched updates for $Count Git repositories under $ParentDir in $($Elapsed.seconds) second(s)"
|
||||
write-host -foregroundColor green "OK - fetched updates for $Count Git repositories under $ParentDir in $($StopWatch.Elapsed.Seconds) second(s)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -10,7 +10,7 @@ param($ParentDir = "$PWD")
|
||||
|
||||
try {
|
||||
"Pulling updates for Git repositories under $ParentDir ..."
|
||||
$StartTime = get-date
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
|
||||
set-location "$ParentDir"
|
||||
@ -31,8 +31,7 @@ try {
|
||||
$Count++
|
||||
}
|
||||
|
||||
$Elapsed = new-timeSpan -start $StartTime -end (get-date)
|
||||
write-host -foregroundColor green "OK - pulled updates for $Count Git repositories under $ParentDir in $($Elapsed.seconds) second(s)"
|
||||
write-host -foregroundColor green "OK - pulled updates for $Count Git repositories under $ParentDir in $($StopWatch.Elapsed.Seconds) second(s)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
@ -13,7 +13,7 @@ if ($Username -eq "") { $Username = read-host "Enter login username" }
|
||||
if ($Password -eq "") { $Password = read-host "Enter login password" }
|
||||
|
||||
try {
|
||||
$StartTime = get-date
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
# check local file first:
|
||||
if (-not(test-path "$File" -pathType leaf)) { throw "Can't access file: $File" }
|
||||
@ -46,8 +46,7 @@ try {
|
||||
$ftpStream.Dispose()
|
||||
$fileStream.Dispose()
|
||||
|
||||
$Elapsed = New-Timespan -start $StartTime -end (get-date)
|
||||
write-host -foregroundColor green "OK - uploaded $File to $URL in $($Elapsed.seconds) second(s)"
|
||||
write-host -foregroundColor green "OK - uploaded $File to $URL in $($StopWatch.Elapsed.Seconds) second(s)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user