Merge pull request #3421 from davidhewitt/codspeed
try adding codspeed benchmarks
This commit is contained in:
commit
d8a6f37fec
40
.github/workflows/benches.yml
vendored
Normal file
40
.github/workflows/benches.yml
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
name: benches
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "main"
|
||||||
|
pull_request:
|
||||||
|
# `workflow_dispatch` allows CodSpeed to trigger backtest
|
||||||
|
# performance analysis in order to generate initial data.
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
benchmarks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
pyo3-benches/target
|
||||||
|
target
|
||||||
|
key: cargo-${{ runner.os }}-bench-${{ hashFiles('**/Cargo.toml') }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Install cargo-codspeed
|
||||||
|
run: cargo install cargo-codspeed
|
||||||
|
|
||||||
|
- name: Install nox
|
||||||
|
run: pip install nox
|
||||||
|
|
||||||
|
- name: Run the benchmarks
|
||||||
|
uses: CodSpeedHQ/action@v1
|
||||||
|
with:
|
||||||
|
run: nox -s codspeed
|
||||||
|
token: ${{ secrets.CODSPEED_TOKEN }}
|
13
noxfile.py
13
noxfile.py
|
@ -137,6 +137,19 @@ def bench(session: nox.Session) -> bool:
|
||||||
_run_cargo(session, "bench", _BENCHES, *session.posargs)
|
_run_cargo(session, "bench", _BENCHES, *session.posargs)
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session()
|
||||||
|
def codspeed(session: nox.Session) -> bool:
|
||||||
|
# rust benchmarks
|
||||||
|
os.chdir(PYO3_DIR / "pyo3-benches")
|
||||||
|
_run_cargo(session, "codspeed", "build")
|
||||||
|
_run_cargo(session, "codspeed", "run")
|
||||||
|
# python benchmarks
|
||||||
|
os.chdir(PYO3_DIR / "pytests")
|
||||||
|
session.install("-r", "requirements-dev.txt", "pytest-codspeed")
|
||||||
|
session.install(".")
|
||||||
|
_run(session, "pytest", "--codspeed", external=True)
|
||||||
|
|
||||||
|
|
||||||
@nox.session(name="clippy-all", venv_backend="none")
|
@nox.session(name="clippy-all", venv_backend="none")
|
||||||
def clippy_all(session: nox.Session) -> None:
|
def clippy_all(session: nox.Session) -> None:
|
||||||
success = True
|
success = True
|
||||||
|
|
|
@ -7,11 +7,13 @@ edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pyo3 = { path = "../", features = ["auto-initialize"] }
|
pyo3 = { path = "../", features = ["auto-initialize", "full"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
codspeed-criterion-compat = "2.3"
|
||||||
criterion = "0.5.1"
|
criterion = "0.5.1"
|
||||||
num-bigint = "0.4.3"
|
num-bigint = "0.4.3"
|
||||||
|
rust_decimal = { version = "1.0.0", default-features = false }
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_any"
|
name = "bench_any"
|
||||||
|
@ -32,17 +34,14 @@ harness = false
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_decimal"
|
name = "bench_decimal"
|
||||||
harness = false
|
harness = false
|
||||||
required-features = ["pyo3/rust_decimal"]
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_dict"
|
name = "bench_dict"
|
||||||
harness = false
|
harness = false
|
||||||
required-features = ["pyo3/hashbrown"]
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_frompyobject"
|
name = "bench_frompyobject"
|
||||||
harness = false
|
harness = false
|
||||||
required-features = ["pyo3/macros"]
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_gil"
|
name = "bench_gil"
|
||||||
|
@ -55,7 +54,6 @@ harness = false
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_pyclass"
|
name = "bench_pyclass"
|
||||||
harness = false
|
harness = false
|
||||||
required-features = ["pyo3/macros"]
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_pyobject"
|
name = "bench_pyobject"
|
||||||
|
@ -64,7 +62,6 @@ harness = false
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_set"
|
name = "bench_set"
|
||||||
harness = false
|
harness = false
|
||||||
required-features = ["pyo3/hashbrown"]
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_tuple"
|
name = "bench_tuple"
|
||||||
|
@ -81,6 +78,5 @@ harness = false
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "bench_bigint"
|
name = "bench_bigint"
|
||||||
harness = false
|
harness = false
|
||||||
required-features = ["pyo3/num-bigint"]
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::{
|
use pyo3::{
|
||||||
types::{
|
types::{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::{types::PyDict, PyAny, Python};
|
use pyo3::{types::PyDict, PyAny, Python};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::{prelude::*, pyclass::CompareOp, Python};
|
use pyo3::{prelude::*, pyclass::CompareOp, Python};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::PyDict;
|
use pyo3::types::PyDict;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::types::IntoPyDict;
|
use pyo3::types::IntoPyDict;
|
||||||
use pyo3::{prelude::*, types::PyMapping};
|
use pyo3::{prelude::*, types::PyMapping};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::{exceptions::PyValueError, prelude::*};
|
use pyo3::{exceptions::PyValueError, prelude::*};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::{
|
use pyo3::{
|
||||||
types::{PyDict, PyFloat, PyInt, PyString},
|
types::{PyDict, PyFloat, PyInt, PyString},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::{
|
use pyo3::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, BatchSize, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, BatchSize, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::{prelude::*, GILPool};
|
use pyo3::{prelude::*, GILPool};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::{PyList, PySequence};
|
use pyo3::types::{PyList, PySequence};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
use pyo3::{impl_::pyclass::LazyTypeObject, prelude::*};
|
use pyo3::{impl_::pyclass::LazyTypeObject, prelude::*};
|
||||||
|
|
||||||
/// This is a feature-rich class instance used to benchmark various parts of the pyclass lifecycle.
|
/// This is a feature-rich class instance used to benchmark various parts of the pyclass lifecycle.
|
||||||
|
@ -26,7 +26,7 @@ impl MyClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn first_time_init(b: &mut criterion::Bencher<'_>) {
|
pub fn first_time_init(b: &mut Bencher<'_>) {
|
||||||
Python::with_gil(|py| {
|
Python::with_gil(|py| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
// This is using an undocumented internal PyO3 API to measure pyclass performance; please
|
// This is using an undocumented internal PyO3 API to measure pyclass performance; please
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::PySet;
|
use pyo3::types::PySet;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
|
use codspeed_criterion_compat::{criterion_group, criterion_main, Bencher, Criterion};
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::{PyList, PySequence, PyTuple};
|
use pyo3::types::{PyList, PySequence, PyTuple};
|
||||||
|
|
Loading…
Reference in a new issue