mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
Move and tidy up small place benchmark
This commit is contained in:
@@ -5,6 +5,29 @@ use tempfile::{tempdir, TempDir};
|
|||||||
|
|
||||||
use librojo::commands::{build, BuildOptions};
|
use librojo::commands::{build, BuildOptions};
|
||||||
|
|
||||||
|
pub fn benchmark_small_place(c: &mut Criterion) {
|
||||||
|
bench_build_place(c, "Small Place", "test-projects/benchmark_small_place")
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, benchmark_small_place);
|
||||||
|
criterion_main!(benches);
|
||||||
|
|
||||||
|
fn bench_build_place(c: &mut Criterion, name: &str, path: &str) {
|
||||||
|
let mut group = c.benchmark_group(name);
|
||||||
|
|
||||||
|
// 'rojo build' generally takes a fair bit of time to execute.
|
||||||
|
group.sample_size(10);
|
||||||
|
group.bench_function("build", |b| {
|
||||||
|
b.iter_batched(
|
||||||
|
|| place_setup(path),
|
||||||
|
|(_dir, options)| build(&options).unwrap(),
|
||||||
|
BatchSize::SmallInput,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
group.finish();
|
||||||
|
}
|
||||||
|
|
||||||
fn place_setup<P: AsRef<Path>>(input_path: P) -> (TempDir, BuildOptions) {
|
fn place_setup<P: AsRef<Path>>(input_path: P) -> (TempDir, BuildOptions) {
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let input = input_path.as_ref().to_path_buf();
|
let input = input_path.as_ref().to_path_buf();
|
||||||
@@ -18,19 +41,3 @@ fn place_setup<P: AsRef<Path>>(input_path: P) -> (TempDir, BuildOptions) {
|
|||||||
|
|
||||||
(dir, options)
|
(dir, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn benchmark_small_place_0_6_0(c: &mut Criterion) {
|
|
||||||
let mut group = c.benchmark_group("Small place");
|
|
||||||
group.sample_size(10);
|
|
||||||
group.bench_function("build", |b| {
|
|
||||||
b.iter_batched(
|
|
||||||
|| place_setup("test-projects/benchmark_project_0.6.0"),
|
|
||||||
|(_dir, options)| build(&options).unwrap(),
|
|
||||||
BatchSize::SmallInput,
|
|
||||||
)
|
|
||||||
});
|
|
||||||
group.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
criterion_group!(benches, benchmark_small_place_0_6_0);
|
|
||||||
criterion_main!(benches);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user