-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase import performance (lru_cache) and add pytest-benchmark (#279)
* Add pytest-benchmark test dependency Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Add performance files for before the changes Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Use cached versions of inspect.getdoc/getsource Fixes #278 Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Make numpy import lazy Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Simplify the benchmark code a bit Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Remove .benchmarks file from git history Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Playing around with GitHub actions for benchmark Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Remove upload workflow, add benchmark Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Tweak benchmark.yml and build.yml Signed-off-by: Fabrice Normandin <normandf@mila.quebec> * Only run workflow on push to master Signed-off-by: Fabrice Normandin <normandf@mila.quebec> --------- Signed-off-by: Fabrice Normandin <normandf@mila.quebec>
- Loading branch information
Showing
9 changed files
with
190 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Benchmark | ||
|
||
# Do not run this workflow on pull request since this workflow has permission to modify contents. | ||
on: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
# deployments permission to deploy GitHub pages website | ||
contents: write | ||
# contents permission to update benchmark contents in gh-pages branch | ||
deployments: write | ||
|
||
jobs: | ||
benchmark: | ||
name: Run pytest-benchmark benchmark example | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.11 | ||
cache: "pip" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -e .[all] | ||
- name: Run benchmark | ||
run: | | ||
pytest --benchmark-only --benchmark-json=.benchmark_output.json | ||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Python Benchmark with pytest-benchmark | ||
tool: 'pytest' | ||
# Where the output from the benchmark tool is stored | ||
output-file-path: .benchmark_output.json | ||
# # Where the previous data file is stored | ||
# external-data-json-path: ./cache/benchmark-data.json | ||
# Use personal access token instead of GITHUB_TOKEN due to https://github.community/t/github-action-not-triggering-gh-pages-upon-push/16096 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# NOTE: auto-push must be false when external-data-json-path is set since this action | ||
# reads/writes the given JSON file and never pushes to remote | ||
auto-push: true | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: '200%' | ||
comment-on-alert: true | ||
# Workflow will fail when an alert happens | ||
fail-on-alert: true | ||
alert-comment-cc-users: '@lebrice' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[pytest] | ||
addopts = --doctest-modules | ||
addopts = --doctest-modules --benchmark-autosave | ||
testpaths = test simple_parsing | ||
norecursedirs = examples .git .tox .eggs dist build docs *.egg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
"pytest", | ||
"pytest-xdist", | ||
"pytest-regressions", | ||
"pytest-benchmark", | ||
"numpy", | ||
# "torch", | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.