Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include benchmark suite and automation for multiple os #1431

Open
wants to merge 3 commits into
base: rc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on: [ push, pull_request ]

name: Benchmark

jobs:
benchmark:
name: Run benchmarks
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v2
nilslice marked this conversation as resolved.
Show resolved Hide resolved
with:
submodules: recursive

- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: '3.7'

- uses: actions/cache@v2
with:
path: .venv
key: poetry-${{ hashFiles('poetry.lock') }}

- name: Download benchmark artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: bench.yml
name: benchmarks-${{ matrix.os }}
path: .benchmarks
continue-on-error: true

- name: Run pytest-benchmark
run: |
. scripts/ci_install_deps
poetry run pytest benchmarks \
--benchmark-compare \
--benchmark-save=main-${{ matrix.os }} \
--benchmark-warmup=on

- name: Archive benchmark results
if: ${{ github.ref == 'refs/heads/main'}}
uses: actions/upload-artifact@v3
with:
name: benchmarks-${{ matrix.os }}
path: .benchmarks
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,5 @@ fabric.properties


node_modules/

.benchmarks
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "quillang"]
path = docs/quil
url = https://github.com/rigetti/quil.git
[submodule "benchmarks/quilc"]
path = benchmarks/quilc
url = https://github.com/quil-lang/quilc.git
Empty file added benchmarks/__init__.py
Empty file.
1 change: 1 addition & 0 deletions benchmarks/quilc
Submodule quilc added at 5d69ac
33 changes: 33 additions & 0 deletions benchmarks/test_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest
import os
import subprocess
from pyquil._parser.parser import run_parser
from pyquil.quil import Program


def from_corpus():
programs = []
dir = os.path.join(os.path.dirname(__file__), "quilc", "tests", "good-test-files")
if not os.path.exists(dir):
subprocess.Popen(["git", "submodule", "update", "--init", "--recursive"]).wait()
genos marked this conversation as resolved.
Show resolved Hide resolved

for path in os.listdir(dir):
filepath = os.path.join(dir, path)
if os.path.isfile(filepath):
file = open(filepath, "r")
program = file.read()
try:
run_parser(program)
programs.append((path, program))
except:
continue
nilslice marked this conversation as resolved.
Show resolved Hide resolved
finally:
file.close()

return programs


@pytest.mark.parametrize("quil", from_corpus())
def test_parser(benchmark, quil):
benchmark.group = "Parse: %s" % quil[0]
benchmark((lambda: Program(run_parser(quil[1]))))
69 changes: 68 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pytest-timeout = "^1.4.2"
pytest-mock = "^3.6.1"
pytest-freezegun = "^0.4.2"
respx = "^0.15"
pytest-benchmark = "^3.4.1"

[tool.poetry.extras]
latex = ["ipython"]
Expand Down