Skip to content

Commit a88a9ff

Browse files
committed
update perf imports
1 parent 741ab91 commit a88a9ff

2 files changed

Lines changed: 42 additions & 26 deletions

File tree

.github/workflows/performance.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: performance
22

33
on:
4-
# push:
5-
# branches: [ main ]
6-
# paths: [ '**.py', 'src/**' ]
4+
release:
5+
types: [ published ]
76
workflow_dispatch:
87

98
concurrency:
@@ -14,7 +13,9 @@ jobs:
1413
perf-import:
1514
runs-on: ${{ matrix.os }}
1615
strategy:
16+
fail-fast: false
1717
matrix:
18+
python: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
1819
os: [ ubuntu-latest, macOS-latest, windows-latest ]
1920

2021
steps:
@@ -28,9 +29,26 @@ jobs:
2829
python -m pip install nox pyperf
2930
- name: Perf importing third-party packages
3031
run: |
31-
sh scripts/perf_import.sh
32+
nox -s test_import_third_party_perf-${{ matrix.python }}
33+
- uses: actions/upload-artifact@v3
34+
with:
35+
name: perf-import
36+
path: "*.json"
37+
38+
perf-import-result:
39+
runs-on: ubuntu-latest
40+
needs: [ perf-import ]
41+
steps:
42+
- uses: actions/setup-python@v4
43+
44+
- name: Download artifact
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: perf-import
48+
path: ./
3249

3350
pyperformance:
51+
if: false
3452
runs-on: ${{ matrix.os }}
3553
strategy:
3654
matrix:

noxfile.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ def _py_version(session: nox.Session):
4343
return out
4444

4545

46+
def _perf_config() -> t.List[str]:
47+
result = []
48+
_run = os.environ.get('RUN', '').lower()
49+
if _run in ('fast', 'short'):
50+
result.append('--fast')
51+
elif _run in ('long', 'rigorous'):
52+
result.append('--rigorous')
53+
return result
54+
55+
4656
def _self_tests(session: nox.Session):
4757
session.install(".")
4858
session.install("pytest")
@@ -180,17 +190,18 @@ def test_import_third_party_perf(session: nox.Session, package):
180190
raw_out = f'perf-import-{session.python}-raw'
181191
cds_out = f'perf-import-{session.python}-cds'
182192

183-
session.run('pyperf', 'command', '--fast', f'--append={raw_out}.json', f'--name={package.name}',
193+
base_cmd = ['pyperf', 'command'] + _perf_config() + [f'--name={package.name}']
194+
195+
session.run(*base_cmd, f'--append={raw_out}.json',
184196
'python', '-c', package.import_stmt)
185-
session.run('pyperf', 'command', '--fast', f'--append={cds_out}.json', f'--name={package.name}',
186-
'--inherit-environ=PYCDSMODE,PYCDSARCHIVE',
197+
session.run(*base_cmd, f'--append={cds_out}.json', '--inherit-environ=PYCDSMODE,PYCDSARCHIVE',
187198
'python', '-c', package.import_stmt,
188199
env={'PYCDSMODE': 'SHARE', 'PYCDSARCHIVE': img})
189200

190201
ci_session_cleanup()
191202

192203

193-
def _pyperformance(session: nox.Session, pyperformance_args=None):
204+
def _pyperformance(session: nox.Session, pyperformance_cmd=None):
194205
session.install(CDS_PYPERFORMANCE)
195206

196207
configs = [
@@ -205,15 +216,17 @@ def _pyperformance(session: nox.Session, pyperformance_args=None):
205216
tmp = session.create_tmp()
206217
session.chdir(tmp)
207218

208-
if pyperformance_args is None:
209-
pyperformance_args = ['pyperformance', 'run']
219+
if pyperformance_cmd is None:
220+
pyperformance_cmd = ['pyperformance', 'run']
221+
222+
pyperformance_cmd += _perf_config()
210223

211224
cmd_exc = None
212225
for out, args in configs:
213226
if os.path.exists(out):
214227
session.run('mv', out, out + '.old')
215228
try:
216-
session.run(*(pyperformance_args + args), f'--out={out}')
229+
session.run(*(pyperformance_cmd + args), f'--out={out}')
217230
except CommandFailed as e:
218231
if cmd_exc is None:
219232
cmd_exc = e
@@ -222,21 +235,6 @@ def _pyperformance(session: nox.Session, pyperformance_args=None):
222235
raise cmd_exc
223236

224237

225-
@nox.session(venv_backend='venv')
226-
def pyperformance_current(session: nox.Session):
227-
_pyperformance(session, ['pyperformance', 'run', '--fast'])
228-
229-
230-
@nox.session(python=SUPPORTED_PYTHONS)
231-
def pyperformance(session: nox.Session):
232-
_pyperformance(session, ['pyperformance', 'run', '--fast'])
233-
234-
235-
@nox.session(python=SUPPORTED_PYTHONS)
236-
def pyperformance_looong(session: nox.Session):
237-
_pyperformance(session, ['pyperformance', 'run', '--rigorous'])
238-
239-
240238
@nox.session(venv_backend='venv')
241239
def build_sdist(session: nox.Session):
242240
"""

0 commit comments

Comments
 (0)