Skip to content

Instantly share code, notes, and snippets.

@haraldfianbakken
Created April 12, 2014 22:12
Show Gist options
  • Save haraldfianbakken/10559398 to your computer and use it in GitHub Desktop.
Save haraldfianbakken/10559398 to your computer and use it in GitHub Desktop.
Powershell performance on huge files
$method1 = [scriptblock]{
gc Data\SwissProt.xml, Data\SwissProt.xml|Set-Content -Path Output.xml
}
$method2 = [scriptblock]{
gc -ReadCount 512 Data\SwissProt.xml, Data\SwissProt.xml|Set-Content -Path Output2.xml;
}
#Measure-Command -Expression $method1;
<#
Days : 0
Hours : 0
Minutes : 3
Seconds : 42
Milliseconds : 713
Ticks : 2227133416
TotalDays : 0,00257770071296296
TotalHours : 0,0618648171111111
TotalMinutes : 3,71188902666667
TotalSeconds : 222,7133416
TotalMilliseconds : 222713,3416
#>
Measure-Command -Expression $method2;
<#
Days : 0
Hours : 0
Minutes : 0
Seconds : 4
Milliseconds : 983
Ticks : 49839060
TotalDays : 5,76840972222222E-05
TotalHours : 0,00138441833333333
TotalMinutes : 0,0830651
TotalSeconds : 4,983906
TotalMilliseconds : 4983,906
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment