76126b1f86e1a0d3922f505076cb341d0d5eeea0
[platform/upstream/coreclr.git] / eng / common / performance / performance-setup.sh
1 #!/usr/bin/env bash
2
3 source_directory=$BUILD_SOURCESDIRECTORY
4 core_root_directory=
5 architecture=x64
6 framework=netcoreapp5.0
7 compilation_mode=tiered
8 repository=$BUILD_REPOSITORY_NAME
9 branch=$BUILD_SOURCEBRANCH
10 commit_sha=$BUILD_SOURCEVERSION
11 build_number=$BUILD_BUILDNUMBER
12 internal=false
13 kind="micro"
14 run_categories="coreclr corefx"
15 csproj="src\benchmarks\micro\MicroBenchmarks.csproj"
16 configurations=
17 run_from_perf_repo=false
18 use_core_run=true
19
20 while (($# > 0)); do
21   lowerI="$(echo $1 | awk '{print tolower($0)}')"
22   case $lowerI in
23     --sourcedirectory)
24       source_directory=$2
25       shift 2
26       ;;
27     --corerootdirectory)
28       core_root_directory=$2
29       shift 2
30       ;;
31     --architecture)
32       architecture=$2
33       shift 2
34       ;;
35     --framework)
36       framework=$2
37       shift 2
38       ;;
39     --compilationmode)
40       compilation_mode=$2
41       shift 2
42       ;;
43     --repository)
44       repository=$2
45       shift 2
46       ;;
47     --branch)
48       branch=$2
49       shift 2
50       ;;
51     --commitsha)
52       commit_sha=$2
53       shift 2
54       ;;
55     --buildnumber)
56       build_number=$2
57       shift 2
58       ;;
59     --kind)
60       kind=$2
61       shift 2
62       ;;
63     --runcategories)
64       run_categories=$2
65       shift 2
66       ;;
67     --csproj)
68       csproj=$2
69       shift 2
70       ;;
71     --internal)
72       internal=true
73       shift 1
74       ;;
75     --configurations)
76       configurations=$2
77       shift 2
78       ;;
79     --help)
80       echo "Common settings:"
81       echo "  --corerootdirectory <value>    Directory where Core_Root exists, if running perf testing with --corerun"
82       echo "  --architecture <value>         Architecture of the testing being run"
83       echo "  --configurations <value>       List of key=value pairs that will be passed to perf testing infrastructure."
84       echo "                                 ex: --configurations \"CompilationMode=Tiered OptimzationLevel=PGO\""
85       echo "  --help                         Print help and exit"
86       echo ""
87       echo "Advanced settings:"
88       echo "  --framework <value>            The framework to run, if not running in master"
89       echo "  --compliationmode <value>      The compilation mode if not passing --configurations"
90       echo "  --sourcedirectory <value>      The directory of the sources. Defaults to env:BUILD_SOURCESDIRECTORY"
91       echo "  --repository <value>           The name of the repository in the <owner>/<repository name> format. Defaults to env:BUILD_REPOSITORY_NAME"
92       echo "  --branch <value>               The name of the branch. Defaults to env:BUILD_SOURCEBRANCH"
93       echo "  --commitsha <value>            The commit sha1 to run against. Defaults to env:BUILD_SOURCEVERSION"
94       echo "  --buildnumber <value>          The build number currently running. Defaults to env:BUILD_BUILDNUMBER"
95       echo "  --csproj                       The relative path to the benchmark csproj whose tests should be run. Defaults to src\benchmarks\micro\MicroBenchmarks.csproj"
96       echo "  --kind <value>                 Related to csproj. The kind of benchmarks that should be run. Defaults to micro"
97       echo "  --runcategories <value>        Related to csproj. Categories of benchmarks to run. Defaults to \"coreclr corefx\""
98       echo "  --internal                     If the benchmarks are running as an official job."
99       echo ""
100       exit 0
101       ;;
102   esac
103 done
104
105 if [[ "$repository" == "dotnet/performance" ]]; then
106     run_from_perf_repo=true
107 fi
108
109 if [ -z "$configurations" ]; then
110     configurations="CompliationMode=$compilation_mode"
111 fi
112
113 if [ -z "$core_root_directory" ]; then
114     use_core_run=false
115 fi
116
117 payload_directory=$source_directory/Payload
118 performance_directory=$payload_directory/performance
119 workitem_directory=$source_directory/workitem
120 extra_benchmark_dotnet_arguments="--iterationCount 1 --warmupCount 0 --invocationCount 1 --unrollFactor 1 --strategy ColdStart --stopOnFirstError true"
121 perflab_arguments=
122 queue=Ubuntu.1804.Amd64.Open
123 creator=$BUILD_DEFINITIONNAME
124 helix_source_prefix="pr"
125
126 if [[ "$internal" == true ]]; then
127     perflab_arguments="--upload-to-perflab-container"
128     helix_source_prefix="official"
129     creator=
130     extra_benchmark_dotnet_arguments=
131     
132     if [[ "$architecture" = "arm64" ]]; then
133         queue=Ubuntu.1804.Arm64.Perf
134     else
135         queue=Ubuntu.1804.Amd64.Tiger.Perf
136     fi
137 fi
138
139 common_setup_arguments="--frameworks $framework --queue $queue --build-number $build_number --build-configs $configurations"
140 setup_arguments="--repository https://github.com/$repository --branch $branch --get-perf-hash --commit-sha $commit_sha $common_setup_arguments"
141
142 if [[ "$run_from_perf_repo" = true ]]; then
143     payload_directory=
144     workitem_directory=$source_directory
145     performance_directory=$workitem_directory
146     setup_arguments="--perf-hash $commit_sha $common_setup_arguments"
147 else
148     git clone --branch master --depth 1 --quiet https://github.com/dotnet/performance $performance_directory
149     
150     docs_directory=$performance_directory/docs
151     mv $docs_directory $workitem_directory
152 fi
153
154 if [[ "$use_core_run" = true ]]; then
155     new_core_root=$payload_directory/Core_Root
156     mv $core_root_directory $new_core_root
157 fi
158
159 ci=true
160
161 _script_dir=$(pwd)/eng/common
162 . "$_script_dir/pipeline-logging-functions.sh"
163
164 # Make sure all of our variables are available for future steps
165 Write-PipelineSetVariable -name "UseCoreRun" -value "$use_core_run" -is_multi_job_variable false
166 Write-PipelineSetVariable -name "Architecture" -value "$architecture" -is_multi_job_variable false
167 Write-PipelineSetVariable -name "PayloadDirectory" -value "$payload_directory" -is_multi_job_variable false
168 Write-PipelineSetVariable -name "PerformanceDirectory" -value "$performance_directory" -is_multi_job_variable false
169 Write-PipelineSetVariable -name "WorkItemDirectory" -value "$workitem_directory" -is_multi_job_variable false
170 Write-PipelineSetVariable -name "Queue" -value "$queue" -is_multi_job_variable false
171 Write-PipelineSetVariable -name "SetupArguments" -value "$setup_arguments" -is_multi_job_variable false
172 Write-PipelineSetVariable -name "Python" -value "$python3" -is_multi_job_variable false
173 Write-PipelineSetVariable -name "PerfLabArguments" -value "$perflab_arguments" -is_multi_job_variable false
174 Write-PipelineSetVariable -name "ExtraBenchmarkDotNetArguments" -value "$extra_benchmark_dotnet_arguments" -is_multi_job_variable false
175 Write-PipelineSetVariable -name "BDNCategories" -value "$run_categories" -is_multi_job_variable false
176 Write-PipelineSetVariable -name "TargetCsproj" -value "$csproj" -is_multi_job_variable false
177 Write-PipelineSetVariable -name "RunFromPerfRepo" -value "$run_from_perf_repo" -is_multi_job_variable false
178 Write-PipelineSetVariable -name "Creator" -value "$creator" -is_multi_job_variable false
179 Write-PipelineSetVariable -name "HelixSourcePrefix" -value "$helix_source_prefix" -is_multi_job_variable false
180 Write-PipelineSetVariable -name "Kind" -value "$kind" -is_multi_job_variable false
181 Write-PipelineSetVariable -name "_BuildConfig" -value "$architecture.$kind.$framework" -is_multi_job_variable false