Skip to content

Commit

Permalink
CI: Add Benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Stevens-Haas committed Aug 1, 2024
1 parent f4ad7b0 commit 26dbb0e
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 1 deletion.
21 changes: 20 additions & 1 deletion .github/workflows/push-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,23 @@ jobs:
# https://github.com/marketplace/actions/install-poetry-action#codecov-upload
# ======
- name: Run tests
run: poetry run pytest
run: poetry run pytest

benchmarks:
name: ASV Benchmarks
needs: test
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Run ASV benchmarks
run: |
cd asv_bench
asv machine --yes
asv run --durations=30 --python=same --show-stderr
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,11 @@ venv.bak/

# Exploratory work
playground/

# Unit / Performance Testing #
##############################
asv_bench/.asv/env/
asv_bench/html/
asv_bench/.asv/results/
asv_bench/derivative/
test-data.xml
14 changes: 14 additions & 0 deletions asv_bench/asv.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": 1,
"project": "derivative",
"project_url": "https://derivative.readthedocs.io/",
"repo": "..",
"environment_type": "virtualenv",
"env_dir": ".asv/env",
"results_dir": ".asv/results",
"html_dir": ".asv/html",
"show_commit_url": "https://github.com/$OWNER/$REPO/commit/",
"build_command": [
"python -m build --outdir {build_cache_dir} {build_dir}"
]
}
Empty file.
31 changes: 31 additions & 0 deletions asv_bench/benchmarks/finite_difference_1D.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Write the benchmarking functions here.
# See "Writing benchmarks" in the asv docs for more information.


class TimeSuite:
"""
An example benchmark that times the performance of various kinds
of iterating over dictionaries in Python.
"""
def setup(self):
self.d = {}
for x in range(500):
self.d[x] = None

def time_keys(self):
for key in self.d.keys():
pass

def time_values(self):
for value in self.d.values():
pass

def time_range(self):
d = self.d
for key in range(500):
d[key]


class MemSuite:
def mem_list(self):
return [0] * 256
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ matplotlib = {version = "^3.2.1", optional = true}
#pandoc = {version = "^2.2", optional = true}

# dev
asv = {version = "^0.6", optional = true}
pytest = {version = "^7", optional = true}

[tool.poetry.extras]
Expand Down

0 comments on commit 26dbb0e

Please sign in to comment.