Skip to content

pystats

pystats #82

Workflow file for this run

name: pystats
"on":
schedule:
# Run every Sunday at midnight
- cron: '0 0 * * 0'
workflow_dispatch:
inputs:
fork:
description: Github user or organization of the CPython fork to analyse
default: python
required: false
branch:
description: Branch to analyse
default: main
required: false
jobs:
collect-stats:
runs-on: ubuntu-latest
steps:
- name: Display configuration
run: |
echo fork ${{ inputs.fork }}
echo branch ${{ inputs.branch }}
# Checkout both the ideas repo and cpython
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v3
with:
repository: ${{ inputs.fork || 'python' }}/cpython
ref: ${{ inputs.branch || 'main' }}
path: cpython
- name: Install Dependencies
run: |
cd cpython
sudo ./.github/workflows/posix-deps-apt.sh
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
- name: Configure ccache action
uses: hendrikmuhs/ccache-action@v1.2
- name: Create pystats directory
run: |
# If we don't do this, stats are printed to the console
mkdir /tmp/py_stats
- name: Compile
run: |
cd cpython
./configure --enable-pystats --prefix=$PWD/install
make -j4
make install
- name: Install pyperformance into the system python
run: |
python -m pip install pyperformance==1.0.6
- name: Collect stats
run: |
# Delete py_stats -- the Python build (deepfreeze etc.) itself creates stats
rm -rf /tmp/py_stats/*
# Run pyperformance itself on the system python, so it doesn't collect stats.
# The benchmarks themselves are run using the python we built here.
python -m pyperformance run --output results.json --python ./cpython/install/bin/python3 || echo "done"
- name: Summarize stats
run: |
# It is important to run `git log` in the cpython directory, so the git hash
# is the CPython one, not the ideas repo one.
cd cpython
# The file suffix is of the form "fork-githash-isodate", e.g. "python-abcdef0-2022-11-28"
export FILE_SUFFIX=`date --rfc-3339=date`-${{ inputs.fork || 'python' }}-`git log --pretty=format:'%h' -n 1`
cd ..
# Needs to run in same version of Python as build so the opcodes and source files match
./cpython/install/bin/python3 ./cpython/Tools/scripts/summarize_stats.py --json-output pystats-${FILE_SUFFIX}.json > pystats-${FILE_SUFFIX}.md
cp pystats-${FILE_SUFFIX}.json stats
cp pystats-${FILE_SUFFIX}.md stats
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: stats
path: |
pystats-*.json
pystats-*.md
- name: Add to repo
uses: EndBug/add-and-commit@v9
with:
add: stats