-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvs-perfcmd.ps1
More file actions
52 lines (37 loc) · 1.55 KB
/
Copy pathvs-perfcmd.ps1
File metadata and controls
52 lines (37 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$env:PATH += "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools;"
function instrument-binaries ([string] $basePath, $assemblies) {
push-location $basePath
if (-not (test-path ( where.exe VsInstr.exe ))) {
write-host "VsInstr.exe is not installed!"
} else {
$assemblies = get-childitem $path | where { $expr.IsMatch($_.Name) } | select Name
foreach ($instr in $assemblies) {
write-host "vsinstr.exe $instr"
VsInstr.exe $instr /ExcludeSmallFuncs
}
}
pop-location
}
function begin-profiling ( [string] $session, [string] $report_path ) {
if (-not (test-path $report_path )) {
mkdir "$report_path"| out-null
}
$env:_NT_SYMBOL_PATH = "srv*C:\mssymbols*http://msdl.microsoft.com/downloads/symbols"
# make sure the profiler isn't already running.
VsPerfCmd.exe /Status
if ($LastExitCode -ne 0) {
$name = $session + [DateTime]::Now.ToString("MM-dd-yyyy-hh-mm")
$report = [system.io.path]::combine($report_path, ($name + ".vsp"))
VsPerfCmd.exe /user:Everyone /start:Trace /output:$report /CrossSession
write-host "Profiling report will be stored in:" $report
} else {
write-host "Profiler already running. New session will not be started."
}
}
function end-profiling {
VsPerfCmd.exe /GlobalOff
VsPerfCmd /Shutdown
VsPerfClrEnv /off
write-host "Profilers detached."
}
# todo: process results with vsperfreport