Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function Get-FolderSizeRC($Path) {
  2. if ( robocopy $Path c:\dummy /e /r:0 /w:0 /b /BYTES /nfl /ndl /np /njh /l | ? { $_ -match 'Bytes :\s*(?<size>\S+)' } ) { return [int64]$Matches.size }
  3. }
  4.  
  5. function Get-FolderSizePS($Path) {
  6. return ( ls -Recurse -Path $Path -Force | measure -Property length -Sum ) | select -ExpandProperty Sum
  7. }
  8.  
  9. function test($Path) {
  10. Write-Host -Object "Testing $Path" -ForegroundColor Cyan
  11. "Read folder size (RC): $([math]::Round((Measure-Command { $size = Get-FolderSizeRC -Path $Path } | select -ExpandProperty TotalSeconds),1))s / $size ($([math]::Round(($size/1Mb)))Mb)"
  12. "Read folder size (PS): $([math]::Round((Measure-Command { $size = Get-FolderSizePS -Path $Path } | select -ExpandProperty TotalSeconds),1))s / $size ($([math]::Round(($size/1Mb)))Mb)"
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement