Merge branch 'master' of https://github.com/dotnet/coreclr into refactor_packaging
[platform/upstream/coreclr.git] / tests / scripts / run-xunit-perf.cmd
1 @rem Licensed to the .NET Foundation under one or more agreements.
2 @rem The .NET Foundation licenses this file to you under the MIT license.
3 @rem See the LICENSE file in the project root for more information.
4
5 @setlocal
6 @echo off
7
8 rem Set defaults for the file extension, architecture and configuration
9 set CORECLR_REPO=%CD%
10 set TEST_FILE_EXT=exe
11 set TEST_ARCH=x64
12 set TEST_CONFIG=Release
13
14 goto :ARGLOOP
15
16 :SETUP
17
18 set CORECLR_OVERLAY=%CORECLR_REPO%\bin\tests\Windows_NT.%TEST_ARCH%.%TEST_CONFIG%\Tests\Core_Root
19 set RUNLOG=%CORECLR_REPO%\bin\Logs\perfrun.log
20
21 if NOT EXIST %CORECLR_OVERLAY% (
22   echo Can't find test overlay directory '%CORECLR_OVERLAY%'
23   echo Please build and run Release CoreCLR tests
24   exit /B 1
25 )
26
27 @echo --- setting up sandbox
28
29 if exist sandbox rd /s /q sandbox
30 if exist sandbox echo ERROR: Failed to remove the sandbox folder& exit /b 1
31 if not exist sandbox mkdir sandbox
32 if not exist sandbox echo ERROR: Failed to create the sandbox folder& exit /b 1
33 pushd sandbox
34
35 @rem stage stuff we need
36
37 @rem xunit and perf
38 xcopy /sy %CORECLR_REPO%\packages\Microsoft.DotNet.xunit.performance.runner.Windows\1.0.0-alpha-build0040\tools\* . > %RUNLOG%
39 xcopy /sy %CORECLR_REPO%\packages\Microsoft.DotNet.xunit.performance.analysis\1.0.0-alpha-build0040\tools\* . >> %RUNLOG%
40 xcopy /sy %CORECLR_REPO%\packages\xunit.console.netcore\1.0.2-prerelease-00177\runtimes\any\native\* . >> %RUNLOG%
41 xcopy /sy %CORECLR_REPO%\bin\tests\Windows_NT.%TEST_ARCH%.%TEST_CONFIG%\Tests\Core_Root\* . >> %RUNLOG%
42
43 @rem find and stage the tests
44 for /R %CORECLR_PERF% %%T in (*.%TEST_FILE_EXT%) do (
45   call :DOIT %%T
46 )
47
48 @rem optionally upload results to benchview
49 if not [%BENCHVIEW_PATH%] == [] (
50   py "%BENCHVIEW_PATH%\submission.py" measurement.json ^
51                                     --build ..\build.json ^
52                                     --machine-data ..\machinedata.json ^
53                                     --metadata ..\submission-metadata.json ^
54                                     --group "CoreCLR" ^
55                                     --type "%RUN_TYPE%" ^
56                                     --config-name "%TEST_CONFIG%" ^
57                                     --config Configuration "%TEST_CONFIG%" ^
58                                     --config OS "Windows_NT" ^
59                                     --arch "%TEST_ARCH%" ^
60                                     --machinepool "PerfSnake"
61   py "%BENCHVIEW_PATH%\upload.py" submission.json --container coreclr
62 )
63
64 goto :EOF
65
66 :DOIT
67 set BENCHNAME=%~n1
68 set BENCHDIR=%~p1
69 set PERFOUT=perf-%BENCHNAME%
70 set XMLOUT=%PERFOUT%-summary.xml
71
72 echo --- Running %BENCHNAME%
73
74 @rem copy benchmark and any input files
75
76 xcopy /s %1 . >> %RUNLOG%
77 xcopy /s %BENCHDIR%*.txt . >> %RUNLOG%
78
79 set CORE_ROOT=%CORECLR_REPO%\sandbox
80
81 xunit.performance.run.exe %BENCHNAME%.%TEST_FILE_EXT% -runner xunit.console.netcore.exe -runnerhost corerun.exe -verbose -runid %PERFOUT% > %BENCHNAME%.out
82
83 xunit.performance.analysis.exe %PERFOUT%.xml -xml %XMLOUT% > %BENCHNAME%-analysis.out
84
85 @rem optionally generate results for benchview
86 if not [%BENCHVIEW_PATH%] == [] (
87   py "%BENCHVIEW_PATH%\measurement.py" xunit "perf-%BENCHNAME%.xml" --better desc --drop-first-value --append
88   REM Save off the results to the root directory for recovery later in Jenkins
89   xcopy perf-%BENCHNAME%*.xml %CORECLR_REPO%\
90   xcopy perf-%BENCHNAME%*.etl %CORECLR_REPO%\
91 ) else (
92   type %XMLOUT% | findstr "test name"
93   type %XMLOUT% | findstr Duration
94   type %XMLOUT% | findstr InstRetired
95 )
96
97 goto :EOF
98
99 :ARGLOOP
100 IF /I [%1] == [-testBinLoc] (
101 set CORECLR_PERF=%CORECLR_REPO%\%2
102 shift
103 shift
104 goto :ARGLOOP
105 )
106 IF /I [%1] == [-runtype] (
107 set RUN_TYPE=%2
108 shift
109 shift
110 goto :ARGLOOP
111 )
112 IF /I [%1] == [-library] (
113 set TEST_FILE_EXT=dll
114 shift
115 goto :ARGLOOP
116 )
117 IF /I [%1] == [-uploadtobenchview] (
118 set BENCHVIEW_PATH=%2
119 shift
120 shift
121 goto :ARGLOOP
122 )
123 IF /I [%1] == [-arch] (
124 set TEST_ARCH=%2
125 shift
126 shift
127 goto :ARGLOOP
128 )
129 IF /I [%1] == [-configuration] (
130 set TEST_CONFIG=%2
131 shift
132 shift
133 goto :ARGLOOP
134 )
135 if /I [%1] == [-?] (
136 goto :USAGE
137 )
138 if /I [%1] == [-help] (
139 goto :USAGE
140 )
141
142 if [%CORECLR_PERF%] == [] (
143 goto :USAGE
144 )
145
146 goto :SETUP
147
148 :USAGE
149 echo run-xunit-perf.cmd -testBinLoc ^<path_to_tests^> [-library] [-arch] ^<x86^|x64^> [-configuration] ^<Release^|Debug^> [-uploadToBenchview] ^<path_to_benchview_tools^> [-runtype] ^<rolling^|private^>
150
151 echo For the path to the tests you can pass a parent directory and the script will grovel for
152 echo all tests in subdirectories and run them.
153 echo The library flag denotes whether the tests are build as libraries (.dll) or an executable (.exe)
154 echo Architecture defaults to x64 and configuration defaults to release.
155 echo -uploadtoBenchview is used to specify a path to the Benchview tooling and when this flag is
156 echo set we will upload the results of the tests to the coreclr container in benchviewupload.
157 echo Runtype sets the runtype that we upload to Benchview, rolling for regular runs, and private for
158 echo PRs.
159
160 goto :EOF