Created
July 12, 2019 13:31
-
-
Save RobsonAutomator/93606d5a77fad6ecec9a4e0e198f9eb4 to your computer and use it in GitHub Desktop.
Performance tests for create a zip archive with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$archivePath = "E:\Test" | |
$folderToArchive = "E:\Temp\FolderToCompress" | |
# prepare output folder | |
mkdir $archivePath -Force | |
Clear-Host | |
for( $i = 0; $i -lt 10; $i++ ) | |
{ | |
$measureExtract = Measure-Command { | |
Add-Type -assembly System.IO.Compression.Filesystem | |
[io.compression.zipfile]::CreateFromDirectory("$folderToArchive", "$archivePath\Create$i.zip", [System.IO.Compression.CompressionLevel]::Optimal, $true ) | |
} | |
$measureExpand = Measure-Command { | |
$ProgressPreference=’SilentlyContinue’ | |
Compress-Archive $folderToArchive "$archivePath\Compress$i.zip" -CompressionLevel Optimal | |
} | |
Write-Host "---" | |
Write-Host "CreateFromDirectory $($measureExtract.Minutes):$($measureExtract.Seconds)" | |
Write-Host "Compress-Archive $($measureExpand.Minutes):$($measureExpand.Seconds)" | |
} | |
# clean output folder | |
rmdir $archivePath -Force -Recurse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment