blob: 79ec2670b043653398e6a8bcd1c33cdc847fbff5 [file] [log] [blame]
Zachary Ware4c9c8482015-04-13 11:59:54 -05001@echo off
2rem A batch program to build PGO (Profile guided optimization) by first
3rem building instrumented binaries, then running the testsuite, and
4rem finally building the optimized code.
5rem Note, after the first instrumented run, one can just keep on
6rem building the PGUpdate configuration while developing.
7
8setlocal
9set platf=Win32
Zachary Ware774ac372015-04-13 12:11:40 -050010set parallel=/m
11set dir=%~dp0
Zachary Ware4c9c8482015-04-13 11:59:54 -050012
13rem use the performance testsuite. This is quick and simple
Zachary Ware774ac372015-04-13 12:11:40 -050014set job1="%dir%..\tools\pybench\pybench.py" -n 1 -C 1 --with-gc
15set path1="%dir%..\tools\pybench"
Zachary Ware4c9c8482015-04-13 11:59:54 -050016
17rem or the whole testsuite for more thorough testing
Zachary Ware774ac372015-04-13 12:11:40 -050018set job2="%dir%..\lib\test\regrtest.py"
19set path2="%dir%..\lib"
Zachary Ware4c9c8482015-04-13 11:59:54 -050020
21set job=%job1%
22set clrpath=%path1%
23
24:CheckOpts
25if "%1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
26if "%1"=="-2" (set job=%job2%) & (set clrpath=%path2%) & shift & goto CheckOpts
Zachary Ware774ac372015-04-13 12:11:40 -050027if "%1"=="-M" (set parallel=) & shift & goto CheckOpts
Zachary Ware4c9c8482015-04-13 11:59:54 -050028
Zachary Ware4c9c8482015-04-13 11:59:54 -050029
Zachary Ware774ac372015-04-13 12:11:40 -050030rem We cannot cross compile PGO builds, as the optimization needs to be run natively
31set vs_platf=x86
32set PGO=%dir%win32-pgo
33
34if "%platf%"=="x64" (set vs_platf=amd64) & (set PGO=%dir%amd64-pgo)
35rem Setup the environment
36call "%dir%env.bat" %vs_platf%
37
38
Zachary Ware4c9c8482015-04-13 11:59:54 -050039rem build the instrumented version
Zachary Ware774ac372015-04-13 12:11:40 -050040msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGInstrument /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9
Zachary Ware4c9c8482015-04-13 11:59:54 -050041
42rem remove .pyc files, .pgc files and execute the job
Zachary Ware774ac372015-04-13 12:11:40 -050043"%PGO%\python.exe" "%dir%rmpyc.py" %clrpath%
44del "%PGO%\*.pgc"
45"%PGO%\python.exe" %job%
Zachary Ware4c9c8482015-04-13 11:59:54 -050046
Zachary Ware774ac372015-04-13 12:11:40 -050047rem build optimized version
48msbuild "%dir%pcbuild.proj" %parallel% /t:Build /p:Configuration=PGUpdate /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9