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