cargo upgrade -p criterion

This commit is contained in:
Bill Thiede 2023-01-21 16:10:13 -08:00
parent 4506418706
commit 27d6c1280b
7 changed files with 389 additions and 249 deletions

539
rtiow/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -7,14 +7,14 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
actix-web = "0.7.8" actix-web = "0.7.19"
askama = "0.7.1" askama = "0.7.2"
image = "0.22.3" image = "0.22.5"
log = "0.4.5" log = "0.4.17"
rand = "0.8.3" rand = "0.8.5"
rand_xorshift = "0.3.0" rand_xorshift = "0.3.0"
renderer = { path = "../renderer" } renderer = { path = "../renderer" }
serde = "1.0.79" serde = "1.0.152"
serde_derive = "1.0.79" serde_derive = "1.0.152"
stderrlog = "0.4.1" stderrlog = "0.4.3"
structopt = "0.2.10" structopt = "0.2.18"

View File

@ -7,13 +7,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
askama = "0.7.1" askama = "0.7.2"
image = "0.22.3" image = "0.22.5"
log = "0.4.5" log = "0.4.17"
rand = "0.5.5" rand = "0.5.6"
renderer = { path = "../renderer" } renderer = { path = "../renderer" }
serde = "1.0.79" serde = "1.0.152"
serde_derive = "1.0.79" serde_derive = "1.0.152"
stderrlog = "0.4.1" stderrlog = "0.4.3"
structopt = "0.2.10" structopt = "0.2.18"
warp = "0.1.20" warp = "0.1.23"

View File

@ -13,21 +13,21 @@ name = "spheres"
chrono = "*" chrono = "*"
core_affinity = "0.5" core_affinity = "0.5"
cpuprofiler = { version = "0.0.3", optional = true } cpuprofiler = { version = "0.0.3", optional = true }
image = "0.22.3" image = "0.22.5"
lazy_static = "1.1.0" lazy_static = "1.4.0"
log = "0.4.5" log = "0.4.17"
num_cpus = "1.8.0" num_cpus = "1.15.0"
rand = "0.8.3" rand = "0.8.5"
serde = "1.0.79" serde = "1.0.152"
serde_derive = "1.0.79" serde_derive = "1.0.152"
serde_json = "1.0.41" serde_json = "1.0.91"
structopt = "0.2.10" structopt = "0.2.18"
vec3 = {path = "../vec3"} vec3 = {path = "../vec3"}
stl = {path = "../../../stl"} stl = {path = "../../../stl"}
#stl = {git = "https://git-private.z.xinu.tv/wathiede/stl"} #stl = {git = "https://git-private.z.xinu.tv/wathiede/stl"}
[dev-dependencies] [dev-dependencies]
criterion = "0.2" criterion = "0.4"
[features] [features]
profile = ["cpuprofiler"] profile = ["cpuprofiler"]

View File

@ -0,0 +1,18 @@
use criterion::*;
fn decode(bytes: &[u8]) {
// Decode the bytes
//...
}
fn bench(c: &mut Criterion) {
let bytes: &[u8] = b"some bytes";
let mut group = c.benchmark_group("throughput-example");
group.throughput(Throughput::Bytes(bytes.len() as u64));
group.bench_function("decode", |b| b.iter(|| decode(bytes)));
group.finish();
}
criterion_group!(benches, bench);
criterion_main!(benches);

View File

@ -1,7 +1,7 @@
#[macro_use] #[macro_use]
extern crate criterion; extern crate criterion;
use criterion::{Criterion, ParameterizedBenchmark}; use criterion::*;
use renderer::{ use renderer::{
hitable::Hit, material::Lambertian, ray::Ray, sphere::Sphere, texture::ConstantTexture, hitable::Hit, material::Lambertian, ray::Ray, sphere::Sphere, texture::ConstantTexture,
@ -20,14 +20,15 @@ fn criterion_benchmark(c: &mut Criterion) {
// Miss // Miss
Ray::new([0., 0., -2.], [0., 0., -1.], 0.), Ray::new([0., 0., -2.], [0., 0., -1.], 0.),
]; ];
c.bench( let mut group = c.benchmark_group("sphere");
"sphere", for r in rays {
ParameterizedBenchmark::new( group.bench_with_input(
"Sphere", BenchmarkId::new("Sphere", format!("{:?}", r)),
move |b, r| b.iter(|| sphere.hit(*r, 0., 1.)), &r,
rays, |b, r| b.iter(|| sphere.hit(*r, 0., 1.)),
), );
); }
group.finish()
} }
criterion_group!(benches, criterion_benchmark); criterion_group!(benches, criterion_benchmark);

View File

@ -7,7 +7,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
log = "0.4.5" log = "0.4.17"
renderer = { path = "../renderer" } renderer = { path = "../renderer" }
stderrlog = "0.4.1" stderrlog = "0.4.3"
structopt = "0.2.10" structopt = "0.2.18"