Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ jobs:
matrix:
project:
- affect_walltime
- pydantic_settings_walltime
- pydantic_walltime
- sqlmodel_walltime
- typer_walltime

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/zizmor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rules:
template-injection:
ignore:
- "diff-pr.yml"
- "diff.yml"
unpinned-uses:
config:
policies:
Expand Down
8 changes: 8 additions & 0 deletions crates/karva_benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ harness = false
name = "affect_walltime"
harness = false

[[bench]]
name = "pydantic_settings_walltime"
harness = false

[[bench]]
name = "pydantic_walltime"
harness = false

[[bench]]
name = "sqlmodel_walltime"
harness = false
Expand Down
18 changes: 18 additions & 0 deletions crates/karva_benchmark/benches/pydantic_settings_walltime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use divan::{Bencher, bench};
use karva_benchmark::walltime::{ProjectBenchmark, bench_project, warmup_project};
use karva_test::real_world_projects::PYDANTIC_SETTINGS_PROJECT;

#[bench(sample_size = 4, sample_count = 5)]
fn pydantic_settings(bencher: Bencher) {
let benchmark = ProjectBenchmark::new(PYDANTIC_SETTINGS_PROJECT.clone());

bench_project(bencher, &benchmark);
}

fn main() {
let benchmark = ProjectBenchmark::new(PYDANTIC_SETTINGS_PROJECT.clone());

warmup_project(&benchmark);

divan::main();
}
18 changes: 18 additions & 0 deletions crates/karva_benchmark/benches/pydantic_walltime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use divan::{Bencher, bench};
use karva_benchmark::walltime::{ProjectBenchmark, bench_project, warmup_project};
use karva_test::real_world_projects::PYDANTIC_PROJECT;

#[bench(sample_size = 4, sample_count = 5)]
fn pydantic(bencher: Bencher) {
let benchmark = ProjectBenchmark::new(PYDANTIC_PROJECT.clone());

bench_project(bencher, &benchmark);
}

fn main() {
let benchmark = ProjectBenchmark::new(PYDANTIC_PROJECT.clone());

warmup_project(&benchmark);

divan::main();
}
5 changes: 3 additions & 2 deletions crates/karva_diff/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn run(
new_temp: &mut NamedTempFile,
accumulation_temp: &mut NamedTempFile,
) -> Result<()> {
println!("testing {:?}", project.name);
let installed_project = project.setup(true)?;

let paths: Vec<String> = installed_project
Expand All @@ -98,7 +99,7 @@ fn run(

let old_output = Command::new("uv")
.arg("run")
.arg("--no-sync")
.arg("--no-project")
.arg(&args.old_karva_binary)
.arg("test")
.args(&paths)
Expand Down Expand Up @@ -126,7 +127,7 @@ fn run(

let new_output = Command::new("uv")
.arg("run")
.arg("--no-sync")
.arg("--no-project")
.arg(&args.new_karva_binary)
.arg("test")
.args(&paths)
Expand Down
74 changes: 61 additions & 13 deletions crates/karva_test/src/real_world_projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct RealWorldProject<'a> {
pub dependencies: &'a [&'a str],
/// Python version to use
pub python_version: PythonVersion,
/// Whether to pip install the project root
pub install_root: bool,
}

impl<'a> RealWorldProject<'a> {
Expand Down Expand Up @@ -262,6 +264,7 @@ fn install_dependencies(checkout: &Checkout, venv_dir: Option<PathBuf>) -> Resul
let output = Command::new("uv")
.args(["pip", "install", "--python", venv_path.to_str().unwrap()])
.args(checkout.project().dependencies)
.arg("--no-build")
.output()
.context("Failed to execute uv pip install command")?;

Expand All @@ -271,17 +274,21 @@ fn install_dependencies(checkout: &Checkout, venv_dir: Option<PathBuf>) -> Resul
String::from_utf8_lossy(&output.stderr)
);

let output = Command::new("uv")
.args(["pip", "install", "--python", venv_path.to_str().unwrap()])
.arg(checkout.project_root())
.output()
.context("Failed to execute uv pip install command")?;
if checkout.project().install_root {
let output = Command::new("uv")
.args(["pip", "install", "--python", venv_path.to_str().unwrap()])
.arg(checkout.project_root())
.output()
.context("Failed to execute uv pip install command")?;

anyhow::ensure!(
output.status.success(),
"Package installation failed: {}",
String::from_utf8_lossy(&output.stderr)
);
anyhow::ensure!(
output.status.success(),
"Package installation failed: {}",
String::from_utf8_lossy(&output.stderr)
);
}

eprintln!("Installed dependencies successfully");

Ok(())
}
Expand Down Expand Up @@ -326,6 +333,7 @@ pub static AFFECT_PROJECT: RealWorldProject<'static> = RealWorldProject {
paths: &["tests"],
dependencies: &["pydantic", "pydantic-settings", "pytest"],
python_version: PythonVersion::PY313,
install_root: true,
};

pub static SQLMODEL_PROJECT: RealWorldProject<'static> = RealWorldProject {
Expand All @@ -345,31 +353,71 @@ pub static SQLMODEL_PROJECT: RealWorldProject<'static> = RealWorldProject {
"jinja2",
],
python_version: PythonVersion::PY313,
install_root: false,
};

pub static TYPER_PROJECT: RealWorldProject<'static> = RealWorldProject {
name: "typer",
repository: "https://github.com/fastapi/typer",
commit: "a9a6595ad74ed59805c085f9d5369e666b955818",
paths: &["tests"],
dependencies: &["click", "typing-extensions", "pytest", "coverage"],
dependencies: &[
"click",
"typing-extensions",
"pytest",
"coverage",
"shellingham",
"rich",
],
python_version: PythonVersion::PY313,
install_root: false,
};

pub static PYDANTIC_SETTINGS_PROJECT: RealWorldProject<'static> = RealWorldProject {
name: "pydantic-settings",
repository: "https://github.com/pydantic/pydantic-settings",
commit: "ffb3ac673633e4f26a512b0fbf986d9bf8821a50",
paths: &["tests"],
dependencies: &["pydantic", "pytest", "python-dotenv", "typing-extensions"],
dependencies: &[
"pydantic",
"pytest",
"python-dotenv",
"typing-extensions",
"pytest-examples",
"pytest-mock",
"pyyaml",
],
python_version: PythonVersion::PY313,
install_root: false,
};

pub static PYDANTIC_PROJECT: RealWorldProject<'static> = RealWorldProject {
name: "pydantic",
repository: "https://github.com/pydantic/pydantic",
commit: "ed67e3ebf7c9a55de75de0e8995dbce36551eaca",
paths: &["tests"],
dependencies: &[
"pytest",
"typing-extensions",
"annotated-types",
"pydantic-core",
"typing-inspection",
"pytest-examples",
"pytest-mock",
"dirty-equals",
"jsonschema",
"pytz",
],
python_version: PythonVersion::PY313,
install_root: false,
};

pub fn all_projects() -> Vec<&'static RealWorldProject<'static>> {
vec![
&AFFECT_PROJECT,
&PYDANTIC_SETTINGS_PROJECT,
&PYDANTIC_PROJECT,
&SQLMODEL_PROJECT,
&TYPER_PROJECT,
&PYDANTIC_SETTINGS_PROJECT,
]
}
Loading