GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Restore CI Benchmark · php-debugger/php-debugger@d0f0b2b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github
    • benchmark-files
      • generate_summary.php
      • xdebug-benchmark.ini
    • workflows
      • benchmark.yml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/benchmark-files/generate_summary.php‎

Copy file name to clipboardExpand all lines: .github/benchmark-files/generate_summary.php
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
sort($phpVersions);
8585

8686
// Sort xdebug modes according to the defined order, leaving only those which actually exist in the data
87-
$xdebugModeOrder = ["no", "off", "coverage", "debug", "develop", "gcstats", "profile", "trace"];
87+
$xdebugModeOrder = ["no", "off", "debug"];
8888
$xdebugModes = array_values(array_filter($xdebugModeOrder, function($mode) use ($xdebugModes) {
8989
return in_array($mode, $xdebugModes);
9090
}));
@@ -282,9 +282,16 @@ function githubApiRequest(string $url): string|false {
282282
*/
283283
function fetchPreviousBenchmarkResults(): array {
284284
// Determine the base branch for comparison
285-
// For pull requests, use GITHUB_BASE_REF
285+
// If COMPARISON_BRANCH is set, use it explicitly
286+
// Otherwise for pull requests, use GITHUB_BASE_REF
286287
// For other actions, use GITHUB_REF_NAME (current branch)
287-
$baseBranch = getenv('GITHUB_BASE_REF') ?: getenv('GITHUB_REF_NAME');
288+
$comparisonBranch = getenv('COMPARISON_BRANCH');
289+
if ($comparisonBranch !== false && $comparisonBranch !== '') {
290+
$baseBranch = $comparisonBranch;
291+
} else {
292+
$baseBranch = getenv('GITHUB_BASE_REF') ?: getenv('GITHUB_REF_NAME');
293+
}
294+
288295
if (!$baseBranch) {
289296
fwrite(STDERR, "Warning: Could not determine base branch for comparison\n");
290297
return [];
Collapse file

‎.github/benchmark-files/xdebug-benchmark.ini‎

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
zend_extension=xdebug
1+
zend_extension=php_debugger.so
22
xdebug.start_with_request=no
33
; We need this because some of the functions in bench.php do deep recursion and the default nesting level is not enough
44
xdebug.max_nesting_level=2048
Collapse file

‎.github/workflows/benchmark.yml‎

Copy file name to clipboard
+193Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: Benchmark Xdebug performance
2+
3+
on:
4+
# This workflow runs on three triggers: Weekly on schedule, manually, or when pull requests are labeled
5+
schedule:
6+
# Every Sunday at 03:00 UTC
7+
- cron: '0 3 * * 0'
8+
workflow_dispatch:
9+
pull_request:
10+
types: [ labeled ]
11+
12+
jobs:
13+
run-benchmark:
14+
# When triggered when a pull request is labeled we check the name of the label
15+
if: |
16+
github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
17+
(
18+
github.event_name == 'pull_request' &&
19+
github.event.label.name == 'performance-check'
20+
)
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
command: ["bench", "symfony", "rector"]
26+
# php: ["8.2", "8.3", "8.4", "8.5"]
27+
php: ["8.2"]
28+
xdebug_mode: ["no", "off", "debug"]
29+
steps:
30+
- uses: actions/checkout@v6
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: "${{ matrix.php }}"
36+
coverage: none
37+
# We need to use a specific version of Composer because we are using a specific version of the
38+
# Symfony Demo which is not compatible with the latest versions of Composer
39+
tools: composer:v2.2.21
40+
41+
- name: Disable ASLR
42+
# ASLR can cause a lot of noise due to missed sse opportunities for memcpy
43+
# and other operations, so we disable it during benchmarking.
44+
run: echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
45+
46+
- name: Install valgrind
47+
run: sudo apt-get update && sudo apt-get install -y valgrind
48+
49+
- name: Compile
50+
run: |
51+
phpize
52+
./configure --enable-php-debugger
53+
make -j$(nproc)
54+
55+
- name: create results and opcache folder
56+
run: |
57+
mkdir -p results
58+
mkdir -p /tmp/opcache
59+
60+
- name: install Symfony demo
61+
if: matrix.command == 'symfony'
62+
# For versions of PHP greater than 8.4 we need to run a different version of the Symfony Demo.
63+
# The older versions suffer from the nulllable parameter deprecation and this generated a lot of
64+
# deprecations in the code and this skewed the tests results a lot. And we cannot use the newer version
65+
# for older versions of PHP as it is not compatible.
66+
run: |
67+
if [ "${{ matrix.php }}" \< "8.4" ]; then
68+
version="v2.0.2"
69+
else
70+
version="v2.7.0"
71+
fi
72+
git clone -q --branch "$version" --depth 1 https://github.com/symfony/demo.git ./symfony-demo
73+
cd symfony-demo
74+
composer install
75+
# We do not want our tests to be skewed by any error, warning, notice or deprecation thrown by the
76+
# code, so we set the error level to 0 on purpose. Unfortunately, Symfony overrides this setup and
77+
# sets their own error reporting level. We fix this by changing all the places where Symfony is
78+
# setting the error reporting level so that it continues to be set to 0
79+
find . -type f -name "*.php" -exec sed -i.bak -E 's/error_reporting\(.*\);/error_reporting(0);/g' {} +
80+
81+
- name: install Rector
82+
if: matrix.command == 'rector'
83+
run: |
84+
composer require rector/rector:2.1.2 phpstan/phpstan:2.1.33 --dev
85+
cp .github/benchmark-files/rector.php .
86+
87+
- name: Copy ini file
88+
run: |
89+
sudo cp ./.github/benchmark-files/benchmark.ini /etc/php/${{ matrix.php }}/cli/conf.d
90+
sudo cp ./.github/benchmark-files/benchmark.ini /etc/php/${{ matrix.php }}/cgi/conf.d
91+
92+
- name: Copy xdebug ini file
93+
if: matrix.xdebug_mode != 'no'
94+
run: |
95+
sudo cp ./.github/benchmark-files/xdebug-benchmark.ini /etc/php/${{ matrix.php }}/cli/conf.d
96+
sudo cp ./.github/benchmark-files/xdebug-benchmark.ini /etc/php/${{ matrix.php }}/cgi/conf.d
97+
98+
- name: Set xdebug mode
99+
run: echo "XDEBUG_MODE=${{ matrix.xdebug_mode }}" >> $GITHUB_ENV
100+
101+
- name: benchmark bench.php
102+
if: matrix.command == 'bench'
103+
run: valgrind --tool=callgrind --dump-instr=yes --callgrind-out-file=callgrind.out -- php ./.github/benchmark-files/bench.php
104+
105+
- name: benchmark Symfony
106+
if: matrix.command == 'symfony'
107+
run: |
108+
cd symfony-demo
109+
# The Symfony demo is run using php-cgi to simulate a web server. Symfony needs that this env
110+
# variable is set, it would usually be set by the web server, we need to set it manually instead
111+
export SCRIPT_FILENAME="$(realpath public/index.php)"
112+
# Symfony also needs this to be set to a non empty value
113+
export APP_SECRET=APP_SECRET
114+
# We run the web page twice so that the files have already been compiled into the opcache in order
115+
# to remove the compilation time from the equation. This also better reflects the normal situation
116+
# in a web server
117+
php-cgi public/index.php
118+
valgrind --tool=callgrind --dump-instr=yes --callgrind-out-file=callgrind.out -- php-cgi public/index.php
119+
mv callgrind.out ..
120+
cd ..
121+
122+
- name: benchmark rector.php
123+
if: matrix.command == 'rector'
124+
# Rector needs to be run with the --xdebug flag so that it does not try to disable Xdebug and also with
125+
# the --debug flag so that it does not try to run several threads in parallel
126+
run: valgrind --tool=callgrind --dump-instr=yes --callgrind-out-file=callgrind.out -- php vendor/bin/rector --dry-run --xdebug --debug || true
127+
128+
- name: save matrix values
129+
run: |
130+
# We read the number of executed instructions from the callgrind.out file and save it in an artifact
131+
# to be processed later
132+
awk '/^summary:/ { print $2 }' callgrind.out > results/php-${{ matrix.php }}_cmd-${{ matrix.command }}_xdebug-${{ matrix.xdebug_mode }}.txt
133+
# We also save the matrix variables so that in a later step we can build a list of the executed
134+
# options
135+
echo "${{ matrix.php }},${{ matrix.command }},${{ matrix.xdebug_mode }}" > results/matrix-values-${{ matrix.php }}-${{ matrix.command }}-${{ matrix.xdebug_mode }}.txt
136+
137+
- name: Upload result and matrix info
138+
uses: actions/upload-artifact@v6
139+
with:
140+
name: results-${{ matrix.command }}-${{ matrix.php }}-${{ matrix.xdebug_mode }}
141+
path: results/
142+
143+
performance:
144+
# After running all benchmarks for all commands, PHP versions and Xdebug modes, we run a new job that builds a
145+
# summary of all execution times
146+
needs: run-benchmark
147+
runs-on: ubuntu-latest
148+
strategy:
149+
fail-fast: false
150+
matrix:
151+
comparison:
152+
- name: "base-branch"
153+
branch: "" # Empty means use default base branch logic
154+
- name: "base"
155+
branch: "base"
156+
steps:
157+
- name: Setup PHP
158+
uses: shivammathur/setup-php@v2
159+
with:
160+
php-version: "8.5"
161+
coverage: none
162+
163+
- uses: actions/checkout@v6
164+
165+
- name: Download all artifacts
166+
uses: actions/download-artifact@v7
167+
with:
168+
path: results
169+
170+
- name: Generate summary table as markdown
171+
env:
172+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173+
COMPARISON_BRANCH: ${{ matrix.comparison.branch }}
174+
run: php .github/benchmark-files/generate_summary.php
175+
176+
- name: print summary
177+
# This generated summary file is copied into a special file which GitHub has defined
178+
# in this special env variable and it will use it to print a summary for the workflow
179+
run: cat summary.md >> $GITHUB_STEP_SUMMARY
180+
181+
- name: delete intermediary artifacts
182+
# The intermediate files that we generated are not needed and can be deleted,
183+
# helping us keep the summary page clean
184+
uses: geekyeggo/delete-artifact@v6
185+
with:
186+
name: results-*
187+
188+
- name: Upload summary.csv as artifact
189+
if: matrix.comparison.name == 'base-branch'
190+
uses: actions/upload-artifact@v6
191+
with:
192+
name: summary.csv
193+
path: summary.csv

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.