@@ -16,20 +16,29 @@ jobs:
16
16
variables :
17
17
runDescription : ${{ parameters.description }}
18
18
functionApp : ${{ parameters.functionAppName }}
19
+ benchmarkArtifactName : benchmark_results_$(functionApp)
19
20
functionAppOutputPath : $(Build.ArtifactStagingDirectory)/FunctionApps/$(functionApp)
20
- benchmarkResultsJsonPath : " $(Build.ArtifactStagingDirectory)/BenchmarkResults/$(buildNumber )_$(functionApp).json"
21
+ benchmarkResultsJsonPath : $(Build.ArtifactStagingDirectory)/BenchmarkResults/$(Build.BuildNumber )_$(functionApp).json
21
22
functionsWorkerRuntime : ' dotnet-isolated'
22
- crankAgentUrl : " http://localhost:5010" # Default crank agent URL.
23
+ crankAgentUrl : " http://localhost:5010" # Default crank agent URL.
23
24
configFilePath : " ./eng/perf/http.benchmarks.yml"
24
25
hostLocation : " ./../../"
26
+ baselineBenchmarkResultFilePath : ' '
27
+ baselineBenchmarkResultsDownloadDir : $(Pipeline.Workspace)/BenchmarkBaselineResult
25
28
26
29
templateContext :
30
+ inputs :
31
+ - input : pipelineArtifact
32
+ artifactName : $(benchmarkArtifactName)
33
+ pipeline : BaselineResult
34
+ targetPath : $(baselineBenchmarkResultsDownloadDir)
35
+
27
36
outputParentDirectory : $(Build.ArtifactStagingDirectory)
28
37
outputs :
29
38
- output : pipelineArtifact
30
39
displayName : Publish benchmark results
31
40
path : $(benchmarkResultsJsonPath)
32
- artifact : ' BenchmarkResults_$(functionApp) '
41
+ artifact : $(benchmarkArtifactName)
33
42
34
43
steps :
35
44
46
55
- script : dotnet tool install -g Microsoft.Crank.Agent --version "0.2.0-*"
47
56
displayName : Install Microsoft.Crank.Agent tool
48
57
49
- - task : PowerShell@2
50
- displayName : Start crank-agent
51
- inputs :
52
- targetType : ' inline'
53
- script : |
54
- Start-Process powershell -ArgumentList '-NoExit', '-Command', 'crank-agent'
58
+ - pwsh : Start-Process powershell -ArgumentList '-NoExit', '-Command', 'crank-agent'
59
+ displayName : ' Start crank-agent'
55
60
56
61
- task : CopyFiles@2
57
62
displayName : Copy benchmark apps to temp location
75
80
- script : dotnet tool install -g Microsoft.Crank.Controller --version "0.2.0-*"
76
81
displayName : Install Microsoft.Crank.Controller
77
82
78
- - task : PowerShell@2
79
- displayName : Run crank-controller
80
- inputs :
81
- targetType : ' inline'
82
- script : |
83
- $crankArgs = "--config $(configFilePath) --scenario hellohttp --profile win2022 --load.options.reuseBuild true --description `"$(runDescription)`" --command-line-property --no-metadata --no-measurements --json $(benchmarkResultsJsonPath) --property sourceVersion=$(sourceVersion) --property buildNumber=$(buildNumber) --property buildId=$(buildId) --variable FunctionsWorkerRuntime=$(functionsWorkerRuntime) --variable HostLocation=$(hostLocation) --variable FunctionAppPath=$(functionAppOutputPath)"
83
+ - pwsh : |
84
+ $crankArgs = "--config $(configFilePath) --scenario hellohttp --profile win2022 --load.options.reuseBuild true --description `"$(runDescription)`" --command-line-property --no-measurements --json $(benchmarkResultsJsonPath) --property sourceVersion=$(Build.SourceVersion) --property buildNumber=$(Build.BuildNumber) --property buildId=$(Build.BuildId) --property sourceBranch=$(Build.SourceBranch) --variable FunctionsWorkerRuntime=$(functionsWorkerRuntime) --variable HostLocation=$(hostLocation) --variable FunctionAppPath=$(functionAppOutputPath)"
84
85
$crankArgs += " ${{ parameters.additionalCrankArgs }}"
85
86
$command = "crank $crankArgs"
86
87
@@ -90,13 +91,40 @@ jobs:
90
91
91
92
Write-Host "Running command: $command"
92
93
Invoke-Expression $command
94
+ displayName: 'Run Benchmark'
93
95
94
- - task : PowerShell@2
95
- displayName : Functions host logs
96
- inputs :
97
- targetType : ' inline'
98
- script : |
99
- $url = "$(crankAgentUrl)/jobs/1/output"
100
- Write-Host "Making GET request to: $url to get logs"
101
- $response = Invoke-WebRequest -Uri $url -Method GET -UseBasicParsing
102
- Write-Host $response.Content
96
+ # Retrieve function host logs
97
+ - pwsh : |
98
+ $url = "$(crankAgentUrl)/jobs/1/output"
99
+ Write-Host "Fetching logs from: $url"
100
+ $response = Invoke-WebRequest -Uri $url -Method GET -UseBasicParsing
101
+ Write-Host $response.Content
102
+ displayName: 'Fetch Function Host Logs'
103
+
104
+ # Tag the build as a baseline if it originates from the specified branch.
105
+ # Baseline builds serve as reference points for performance comparisons in future builds.
106
+ # The tag added here will help identify these builds in the pipeline.
107
+ - pwsh : |
108
+ Write-Host "##vso[build.addbuildtag]$(benchmarkBaselineTagName)"
109
+ condition: and(succeeded(), eq(variables['Build.SourceBranch'], variables['benchmarkBaselineBranch']))
110
+ displayName: 'Tag Build as Baseline'
111
+
112
+ # Locate baseline benchmark result file from the downloaded baseline artifact.
113
+ - pwsh : |
114
+ $baselineDir = "$(baselineBenchmarkResultsDownloadDir)"
115
+ $fileNamePattern = "*_$(functionApp).json"
116
+ $baselineFile = Get-ChildItem -Path $baselineDir -Filter $fileNamePattern | Select-Object -First 1
117
+
118
+ if ($baselineFile) {
119
+ Write-Host "Found baseline benchmark result file: $($baselineFile.FullName)"
120
+ Write-Host "##vso[task.setvariable variable=baselineBenchmarkResultFilePath]$($baselineFile.FullName)"
121
+ } else {
122
+ Write-Host "No baseline benchmark result file found."
123
+ }
124
+ displayName: 'Set Baseline Benchmark Result File Path'
125
+
126
+ # Compare results with baseline
127
+ - pwsh : |
128
+ crank compare "$(baselineBenchmarkResultFilePath)" "$(benchmarkResultsJsonPath)"
129
+ condition: and(succeeded(), ne(variables['baselineBenchmarkResultFilePath'], ''))
130
+ displayName: 'Compare Results with Baseline'
0 commit comments