# Testscript für Verzögerung durch Write-host Ausgaben zu messen param ( $iteration = 1000 ) Write-Host "Start test: Nur Write-Host" $start = Get-Date 1..$iteration | ForEach-Object { Write-Host "$(Get-Date -f o)$($_)" } $end = Get-Date Write-Host "End test: Nur Write-Host" Write-Host "Duration: $($end - $start)" read-host "Press Enter to continue..." Write-Host "Start test: Nur Write-Host mit Transcript" $start = Get-Date start-transcript "transcript.txt" 1..$iteration | ForEach-Object { Write-Host "$(Get-Date -f o)$($_)" } stop-transcript $end = Get-Date Write-Host "End test: Nur Write-Host mit Transcript" Write-Host "Duration: $($end - $start)" read-host "Press Enter to continue..." Write-Host "Start test: Write-Host mit out-file -append" $start = Get-Date 1..$iteration | ForEach-Object { Write-Host "$(Get-Date -f o)$($_)" "$(Get-Date -f o)$($_)" | Out-File -Append "output.txt" } $end = Get-Date Write-Host "End test: Write-Host mit out-file -append" Write-Host "Duration: $($end - $start)" read-host "Press Enter to continue..." Write-Host "Start test: Write-Host mit StreamWriter" $start = Get-Date $outfile = New-Object System.IO.StreamWriter ".\logfile.txt" 1..$iteration | ForEach-Object { Write-Host "$(Get-Date -f o)$($_)" $outfile.WriteLine("$(Get-Date -f o)$($_)") } $outfile.Close(); $end = Get-Date Write-Host "End test: Write-Host mit StreamWriter" Write-Host "Duration: $($end - $start)" read-host "Press Enter to continue..." Write-Host "Start test: Ohne Write-Host mit StreamWriter" $start = Get-Date $outfile = New-Object System.IO.StreamWriter ".\logfile.txt" 1..$iteration | ForEach-Object { $outfile.WriteLine("$(Get-Date -f o)$($_)") } $outfile.Close(); $end = Get-Date Write-Host "End test: Ohne Write-Host mit StreamWriter" Write-Host "Duration: $($end - $start)" read-host "Press Enter to continue..." Write-Host "Starting test: Keine Write-Host mit Out-File" $start = Get-Date 1..$iteration | ForEach-Object { "$(Get-Date -f o)$($_)" | Out-File -Append "output.txt" } $end = Get-Date Write-Host "End test: Keine Write-Host mit Out-File" Write-Host "Duration: $($end - $start)"