[librsvg: 1/12] Add benchmarks for SharedImageSurface::from_pixbuf()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/12] Add benchmarks for SharedImageSurface::from_pixbuf()
- Date: Tue, 13 Oct 2020 14:03:23 +0000 (UTC)
commit a44c091086a09f195cdda8602ff6ddda1e68aeb6
Author: Sven Neumann <sven svenfoo org>
Date: Sun Oct 11 17:24:41 2020 +0200
Add benchmarks for SharedImageSurface::from_pixbuf()
librsvg/benches/pixbuf_from_surface.rs | 4 +--
rsvg_internals/Cargo.toml | 6 ++++-
rsvg_internals/benches/surface_from_pixbuf.rs | 35 +++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 4 deletions(-)
---
diff --git a/librsvg/benches/pixbuf_from_surface.rs b/librsvg/benches/pixbuf_from_surface.rs
index fa237495..b34f31b5 100644
--- a/librsvg/benches/pixbuf_from_surface.rs
+++ b/librsvg/benches/pixbuf_from_surface.rs
@@ -38,9 +38,7 @@ fn bench_pixbuf_from_surface(c: &mut Criterion) {
let surface = surface.share().unwrap();
- b.iter(|| {
- let _pixbuf = pixbuf_from_surface(&surface).unwrap();
- })
+ b.iter(|| pixbuf_from_surface(&surface).unwrap())
});
}
diff --git a/rsvg_internals/Cargo.toml b/rsvg_internals/Cargo.toml
index 4009ebe0..f049391b 100644
--- a/rsvg_internals/Cargo.toml
+++ b/rsvg_internals/Cargo.toml
@@ -66,6 +66,10 @@ harness = false
name = "lighting"
harness = false
+[[bench]]
+name = "path_parser"
+harness = false
+
[[bench]]
name = "pixel_iterators"
harness = false
@@ -75,5 +79,5 @@ name = "srgb"
harness = false
[[bench]]
-name = "path_parser"
+name = "surface_from_pixbuf"
harness = false
diff --git a/rsvg_internals/benches/surface_from_pixbuf.rs b/rsvg_internals/benches/surface_from_pixbuf.rs
new file mode 100644
index 00000000..b59b9bc1
--- /dev/null
+++ b/rsvg_internals/benches/surface_from_pixbuf.rs
@@ -0,0 +1,35 @@
+use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
+use gdk_pixbuf::{Colorspace, Pixbuf};
+use std::time::Duration;
+
+use rsvg_internals::surface_utils::shared_surface::SharedImageSurface;
+
+fn bench_surface_from_pixbuf(c: &mut Criterion) {
+ let mut group = c.benchmark_group("surface_from_pixbuf");
+
+ for input in [false, true].iter() {
+ group.bench_with_input(
+ BenchmarkId::from_parameter(format!("{:?}", input)),
+ input,
+ |b, alpha| {
+ let pixbuf = Pixbuf::new(Colorspace::Rgb, *alpha, 8, 256, 256).unwrap();
+
+ // Fill the surface with interesting data
+ for y in 0..pixbuf.get_width() {
+ for x in 0..pixbuf.get_height() {
+ pixbuf.put_pixel(x, y, x as u8, y as u8, x.max(y) as u8, 0xff);
+ }
+ }
+
+ b.iter(|| SharedImageSurface::from_pixbuf(&pixbuf, None, None).unwrap())
+ },
+ );
+ }
+}
+
+criterion_group!(
+ name = benches;
+ config = Criterion::default().measurement_time(Duration::from_secs(10));
+ targets = bench_surface_from_pixbuf,
+);
+criterion_main!(benches);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]