$Iterations = 500 $Files = 100 #Create Folder to store temp files $MetricFolder = New-Item -ItemType Directory -Path "$($env:USERPROFILE)\Desktop\MetricTest" #Create Files for($I=0;$I -lt $Files; $I++) { "ASDFTESTASDF" | Out-File -FilePath (Join-Path -Path $MetricFolder.FullName -ChildPath "$I.txt") } $GetSingleMetrics = Measure-Command -Expression { for($It=0; $It -lt $Iterations; $It++){ for($I=0;$I -lt $Files; $I++) { $null = Get-Item -Path (Join-Path -Path $MetricFolder.FullName -ChildPath "$I.txt") } } } $GetAllNameMetrics = Measure-Command -Expression { for($It=0; $It -lt $Iterations; $It++){ $null = Get-ChildItem -Path $MetricFolder.FullName -Name } } $GetAllMetrics = Measure-Command -Expression { for($It=0; $It -lt $Iterations; $It++){ $null = Get-ChildItem -Path $MetricFolder.FullName } } $GetAllAndQueryMetrics = Measure-Command -Expression { for($It=0; $It -lt $Iterations; $It++){ $ResultArray = Get-ChildItem -Path $MetricFolder.FullName $ResultHashTable = @{} foreach ($File in $ResultArray) { $ResultHashTable.Add($File.FullName, $File) } for($I=0;$I -lt $Files; $I++) { $null = $ResultHashTable[(Join-Path -Path $MetricFolder.FullName -ChildPath "$I.txt")] } } } $GetAllFilterMetrics = Measure-Command -Expression { for($It=0; $It -lt $Iterations; $It++){ $null = Get-Item -Path "$($MetricFolder.FullName)\*" } } #Create More Files for($I=$Files;$I -lt $Files*2; $I++) { "ASDFTESTASDF" | Out-File -FilePath (Join-Path -Path $MetricFolder.FullName -ChildPath "$I.txt") } $GetAllAndQueryWithExtraMetrics = Measure-Command -Expression { for($It=0; $It -lt $Iterations; $It++){ $ResultArray = Get-ChildItem -Path $MetricFolder.FullName $ResultHashTable = @{} foreach ($File in $ResultArray) { $ResultHashTable.Add($File.FullName, $File) } for($I=0;$I -lt $Files; $I++) { $null = $ResultHashTable[(Join-Path -Path $MetricFolder.FullName -ChildPath "$I.txt")] } } } #Cleanup $MetricFolder | Remove-Item -Recurse