Something performance oriented that I spent way too much time with...
## Use ps to measure WS difference
## Run '.\ws_diff [Measure Interval in Seconds]' or
## to log to text continually every 10 seconds --
## 'while (1) {.\WS_diff.ps1 10 >> ps_out.txt }'
# Take Measurements $Now and $Then and $Count
$then = ps | %{$_ | Select Name,ID, WorkingSet}
sleep -seconds $args[0]
$now = ps | %{$_ | Select Name,ID, WorkingSet}
$count = ($now | Select Name).count
# Declare Time Measurement and Interval
$date = (get-date -format g)
$hour = [DateTime]::UtcNow.TimeOfDay.Hours
$Minutes = [DateTime]::UtcNow.TimeOfDay.Minutes
$seconds = [DateTime]::UtcNow.TimeOfDay.Seconds
$ms = [DateTime]::UtcNow.TimeOfDay.Milliseconds
$interval = $args[0]
## write output and find difference
$text_out = 0..$count |
%{
$date + "," + $hour + ":" + $Minutes + ":" + $seconds + ":" + $ms + "," +
$interval + "," + $Now[$_].Name + "," + $Now[$_].ID + "," +
( ($then[$_].WorkingSet) - ($Now[$_].WorkingSet) )
}
write $text_out
Produces csv output like:
12/30/2008 12:53 PM,20:53:58:953,10,AcroRd32,2204,0
12/30/2008 12:53 PM,20:53:58:953,10,alg,1648,0
12/30/2008 12:53 PM,20:53:58:953,10,CepstralLicSrv,476,0
12/30/2008 12:53 PM,20:53:58:953,10,chrome,336,-4096
12/30/2008 12:53 PM,20:53:58:953,10,chrome,2416,0
12/30/2008 12:53 PM,20:53:58:953,10,chrome,2580,0
12/30/2008 12:53 PM,20:53:58:953,10,chrome,2660,-77824
...