[librsvg: 1/5] (#219) Add benchmark in preparation to lex then parse path data.
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/5] (#219) Add benchmark in preparation to lex then parse path data.
- Date: Thu, 11 Jun 2020 22:07:17 +0000 (UTC)
commit 64bdd7801b5a5ba5dd4891639b1c44119fb4b06b
Author: Emile Snyder <emile snyder gmail com>
Date: Sun Jun 7 10:02:11 2020 -0700
(#219) Add benchmark in preparation to lex then parse path data.
Makefile.am | 1 +
rsvg_internals/Cargo.toml | 4 ++++
rsvg_internals/benches/path_parser.rs | 22 ++++++++++++++++++++++
rsvg_internals/src/lib.rs | 4 ++--
4 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 26324915..4d909d19 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -136,6 +136,7 @@ RUST_EXTRA = \
rsvg_internals/benches/box_blur.rs \
rsvg_internals/benches/composite.rs \
rsvg_internals/benches/lighting.rs \
+ rsvg_internals/benches/path_parser.rs \
rsvg_internals/benches/pixel_iterators.rs \
rsvg_internals/benches/srgb.rs \
rsvg_internals/src/ua.css \
diff --git a/rsvg_internals/Cargo.toml b/rsvg_internals/Cargo.toml
index 223fa3e5..08a73243 100644
--- a/rsvg_internals/Cargo.toml
+++ b/rsvg_internals/Cargo.toml
@@ -71,3 +71,7 @@ harness = false
[[bench]]
name = "srgb"
harness = false
+
+[[bench]]
+name = "path_parser"
+harness = false
diff --git a/rsvg_internals/benches/path_parser.rs b/rsvg_internals/benches/path_parser.rs
new file mode 100644
index 00000000..d8c892e4
--- /dev/null
+++ b/rsvg_internals/benches/path_parser.rs
@@ -0,0 +1,22 @@
+#[macro_use]
+extern crate criterion;
+use criterion::{black_box, Criterion};
+
+use rsvg_internals::path_builder::PathBuilder;
+use rsvg_internals::path_parser::parse_path_into_builder;
+
+static INPUT: &'static str = "M10 20 C 30,40 50 60-70,80,90 100,110 120,130,140";
+
+fn path_parser(c: &mut Criterion) {
+ c.bench_function("parse path into builder", |b| {
+ let input = black_box(INPUT);
+ let mut builder = PathBuilder::new();
+
+ b.iter(|| {
+ let _ = parse_path_into_builder(&input, &mut builder);
+ });
+ });
+}
+
+criterion_group!(benches, path_parser);
+criterion_main!(benches);
diff --git a/rsvg_internals/src/lib.rs b/rsvg_internals/src/lib.rs
index 84aa67fd..b4d88dc0 100644
--- a/rsvg_internals/src/lib.rs
+++ b/rsvg_internals/src/lib.rs
@@ -115,8 +115,8 @@ mod limits;
mod marker;
mod number_list;
mod paint_server;
-mod path_builder;
-mod path_parser;
+pub mod path_builder; // pub for benchmarking
+pub mod path_parser; // pub for benchmarking
mod pattern;
mod properties;
mod property_bag;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]