@@ -124,6 +124,105 @@ jobs:
124124 PYTHON_VERSION: $(PYTHON_VERSION)
125125 workingDirectory: $(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}
126126
127+ - bash : |
128+ PY_VER="$(PYTHON_VERSION)"
129+ PY_MINOR="${PY_VER#*.}"
130+
131+ if [ "$PY_MINOR" -ge 13 ] && [ -f profile_results/dispatcher_session_profile.json ]; then
132+ echo "Checking for baseline profile to compare against..."
133+
134+ # Check if this is a PR build
135+ if [ -n "$(System.PullRequest.PullRequestId)" ]; then
136+ echo "=========================================="
137+ echo "PR Build Detected - Running Comparison"
138+ echo "PR #$(System.PullRequest.PullRequestId)"
139+ echo "=========================================="
140+
141+ # Download baseline from dev branch
142+ chmod +x eng/scripts/download-baseline-profile.sh
143+
144+ if eng/scripts/download-baseline-profile.sh \
145+ "$(System.TeamFoundationCollectionUri)" \
146+ "$(System.TeamProject)" \
147+ "$(System.DefinitionId)" \
148+ "performance-profile-python-$(PYTHON_VERSION)" \
149+ "baseline_results"; then
150+
151+ echo ""
152+ echo "✓ Baseline downloaded successfully"
153+
154+ # Find the baseline JSON file (might be in subdirectory)
155+ BASELINE_FILE=$(find baseline_results -name "dispatcher_session_profile.json" | head -1)
156+
157+ if [ -n "$BASELINE_FILE" ]; then
158+ echo "Running performance comparison..."
159+
160+ python tests/unittest_proxy/compare_profiles.py \
161+ "$BASELINE_FILE" \
162+ profile_results/dispatcher_session_profile.json \
163+ --output profile_results/comparison_report.txt \
164+ --show-all
165+
166+ echo ""
167+ echo "╔════════════════════════════════════════════════════════════╗"
168+ echo "║ PERFORMANCE COMPARISON REPORT (vs dev branch) ║"
169+ echo "╚════════════════════════════════════════════════════════════╝"
170+ cat profile_results/comparison_report.txt
171+ echo ""
172+
173+ # Check for regressions and create warnings
174+ REGRESSION_COUNT=$(grep -c "REGRESSION" profile_results/comparison_report.txt || echo "0")
175+
176+ if [ "$REGRESSION_COUNT" -gt 0 ]; then
177+ echo "##vso[task.logissue type=warning]⚠️ $REGRESSION_COUNT performance regression(s) detected!"
178+ echo "##vso[task.logissue type=warning]Review the comparison report in the artifacts for details."
179+ else
180+ echo "✓ No performance regressions detected"
181+ fi
182+
183+ # Upload comparison to build summary
184+ echo "##vso[task.uploadsummary]$(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}/profile_results/comparison_report.txt"
185+ else
186+ echo "⚠ Could not find baseline JSON file in downloaded artifact"
187+ fi
188+ else
189+ echo ""
190+ echo "⚠ Could not download baseline - comparison skipped"
191+ echo "This might be the first profiling run, or the baseline is unavailable"
192+ fi
193+ else
194+ echo "=========================================="
195+ echo "Main/Dev Branch Build"
196+ echo "=========================================="
197+ echo "This profile will serve as baseline for future PR comparisons"
198+ echo "Artifact: performance-profile-python-$(PYTHON_VERSION)"
199+ fi
200+ else
201+ echo "Skipping baseline comparison (no profile results or Python < 3.13)"
202+ fi
203+ displayName: "Compare Performance Against Baseline"
204+ condition: succeededOrFailed()
205+ env:
206+ PYTHON_VERSION: $(PYTHON_VERSION)
207+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
208+ workingDirectory: $(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}
209+
210+ - bash : |
211+ PY_VER="$(PYTHON_VERSION)"
212+ PY_MINOR="${PY_VER#*.}"
213+
214+ if [ "$PY_MINOR" -ge 13 ] && [ -d profile_results ]; then
215+ echo "Uploading performance profile artifact..."
216+ echo "##vso[artifact.upload artifactname=performance-profile-python-$(PYTHON_VERSION)]$(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}/profile_results"
217+ echo "Performance profile artifact uploaded successfully"
218+ else
219+ echo "Skipping artifact upload (no profile results)"
220+ fi
221+ displayName: "Upload Performance Profile Artifact"
222+ env:
223+ PYTHON_VERSION: $(PYTHON_VERSION)
224+ workingDirectory: $(Build.SourcesDirectory)/${{ parameters.PROJECT_DIRECTORY }}
225+
127226 - bash : |
128227 echo "Cleaning up after tests..."
129228 # Remove build artifacts and caches
0 commit comments