Merge pull request #8135 from pgavlin/fixExtendPtrVN
[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 PERFOUT=perf-%BENCHNAME%
69 set XMLOUT=%PERFOUT%-summary.xml
70
71 echo --- Running %BENCHNAME%
72
73 xcopy /s %1 . >> %RUNLOG%
74
75 set CORE_ROOT=%CORECLR_REPO%\sandbox
76
77 xunit.performance.run.exe %BENCHNAME%.%TEST_FILE_EXT% -runner xunit.console.netcore.exe -runnerhost corerun.exe -verbose -runid %PERFOUT% > %BENCHNAME%.out
78
79 xunit.performance.analysis.exe %PERFOUT%.xml -xml %XMLOUT% > %BENCHNAME%-analysis.out
80
81 @rem optionally generate results for benchview
82 if not [%BENCHVIEW_PATH%] == [] (
83   py "%BENCHVIEW_PATH%\measurement.py" xunit "perf-%BENCHNAME%.xml" --better desc --drop-first-value --append
84   REM Save off the results to the root directory for recovery later in Jenkins
85   xcopy perf-%BENCHNAME%*.xml %CORECLR_REPO%\
86   xcopy perf-%BENCHNAME%*.etl %CORECLR_REPO%\
87 ) else (
88   type %XMLOUT% | findstr "test name"
89   type %XMLOUT% | findstr Duration
90   type %XMLOUT% | findstr InstRetired
91 )
92
93 goto :EOF
94
95 :ARGLOOP
96 IF /I [%1] == [-testBinLoc] (
97 set CORECLR_PERF=%CORECLR_REPO%\%2
98 shift
99 shift
100 goto :ARGLOOP
101 )
102 IF /I [%1] == [-runtype] (
103 set RUN_TYPE=%2
104 shift
105 shift
106 goto :ARGLOOP
107 )
108 IF /I [%1] == [-library] (
109 set TEST_FILE_EXT=dll
110 shift
111 goto :ARGLOOP
112 )
113 IF /I [%1] == [-uploadtobenchview] (
114 set BENCHVIEW_PATH=%2
115 shift
116 shift
117 goto :ARGLOOP
118 )
119 IF /I [%1] == [-arch] (
120 set TEST_ARCH=%2
121 shift
122 shift
123 goto :ARGLOOP
124 )
125 IF /I [%1] == [-configuration] (
126 set TEST_CONFIG=%2
127 shift
128 shift
129 goto :ARGLOOP
130 )
131 if /I [%1] == [-?] (
132 goto :USAGE
133 )
134 if /I [%1] == [-help] (
135 goto :USAGE
136 )
137
138 if [%CORECLR_PERF%] == [] (
139 goto :USAGE
140 )
141
142 goto :SETUP
143
144 :USAGE
145 echo run-xunit-perf.cmd -testBinLoc ^<path_to_tests^> [-library] [-arch] ^<x86^|x64^> [-configuration] ^<Release^|Debug^> [-uploadToBenchview] ^<path_to_benchview_tools^> [-runtype] ^<rolling^|private^>
146
147 echo For the path to the tests you can pass a parent directory and the script will grovel for
148 echo all tests in subdirectories and run them.
149 echo The library flag denotes whether the tests are build as libraries (.dll) or an executable (.exe)
150 echo Architecture defaults to x64 and configuration defaults to release.
151 echo -uploadtoBenchview is used to specify a path to the Benchview tooling and when this flag is
152 echo set we will upload the results of the tests to the coreclr container in benchviewupload.
153 echo Runtype sets the runtype that we upload to Benchview, rolling for regular runs, and private for
154 echo PRs.
155
156 goto :EOF