From 31e067b55d518d322b2b3c288e61e48608dd4978 Mon Sep 17 00:00:00 2001 From: unlimitedbacon Date: Sun, 29 May 2022 23:39:30 -0700 Subject: [PATCH] Separate benchmarks --- Cargo.lock | 190 +++++++++++++++++------------------------- Cargo.toml | 14 +++- benches/benchmarks.rs | 53 ------------ benches/benchy.rs | 25 ++++++ benches/cube.rs | 25 ++++++ benches/shipwreck.rs | 25 ++++++ 6 files changed, 161 insertions(+), 171 deletions(-) delete mode 100644 benches/benchmarks.rs create mode 100644 benches/benchy.rs create mode 100644 benches/cube.rs create mode 100644 benches/shipwreck.rs diff --git a/Cargo.lock b/Cargo.lock index 0555c0f..e50271c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,15 +29,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "approx" version = "0.4.0" @@ -148,11 +139,11 @@ dependencies = [ [[package]] name = "cbindgen" -version = "0.18.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97449daf9b8c245bcad10bbc7c9f4a37c06172c18dd5f9fac340deefc309b957" +checksum = "5b6d248e3ca02f3fbfabcb9284464c596baec223a26d91bbf44a5a62ddb0d900" dependencies = [ - "clap 2.34.0", + "clap 3.1.18", "heck", "indexmap", "log", @@ -222,13 +213,9 @@ version = "2.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ - "ansi_term", - "atty", "bitflags", - "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", - "vec_map", ] [[package]] @@ -241,7 +228,7 @@ dependencies = [ "bitflags", "clap_lex", "indexmap", - "strsim 0.10.0", + "strsim", "termcolor", "textwrap 0.15.0", ] @@ -255,15 +242,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "cocoa" version = "0.24.0" @@ -394,9 +372,9 @@ dependencies = [ [[package]] name = "criterion" -version = "0.2.11" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" +checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" dependencies = [ "atty", "cast", @@ -405,14 +383,13 @@ dependencies = [ "csv", "itertools", "lazy_static", - "libc", "num-traits", - "rand_core 0.3.1", - "rand_os", - "rand_xoshiro", + "oorandom", + "plotters", "rayon", - "rayon-core", + "regex", "serde", + "serde_cbor", "serde_derive", "serde_json", "tinytemplate", @@ -421,11 +398,10 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.3.1" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" +checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" dependencies = [ - "byteorder", "cast", "itertools", ] @@ -523,7 +499,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim", "syn", ] @@ -652,12 +628,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures-core" version = "0.3.21" @@ -806,12 +776,9 @@ checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" [[package]] name = "heck" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hermit-abi" @@ -881,9 +848,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.8.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" dependencies = [ "either", ] @@ -1224,6 +1191,12 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "os_str_bytes" version = "6.1.0" @@ -1296,6 +1269,34 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +[[package]] +name = "plotters" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" + +[[package]] +name = "plotters-svg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +dependencies = [ + "plotters-backend", +] + [[package]] name = "png" version = "0.17.5" @@ -1336,45 +1337,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_xoshiro" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b418169fb9c46533f326efd6eed2576699c44ca92d3052a066214a8d828929" -dependencies = [ - "byteorder", - "rand_core 0.3.1", -] - [[package]] name = "raw-window-handle" version = "0.4.3" @@ -1409,21 +1371,21 @@ dependencies = [ ] [[package]] -name = "rdrand" -version = "0.4.0" +name = "redox_syscall" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ - "rand_core 0.3.1", + "bitflags", ] [[package]] -name = "redox_syscall" -version = "0.2.13" +name = "regex" +version = "1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" dependencies = [ - "bitflags", + "regex-syntax", ] [[package]] @@ -1432,6 +1394,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +[[package]] +name = "regex-syntax" +version = "0.6.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -1504,6 +1472,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.137" @@ -1610,12 +1588,6 @@ dependencies = [ "float-cmp", ] -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.10.0" @@ -1761,24 +1733,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" -[[package]] -name = "unicode-segmentation" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" - [[package]] name = "unicode-width" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "walkdir" version = "2.3.2" diff --git a/Cargo.toml b/Cargo.toml index 2a79ef5..5431a81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,13 +34,21 @@ stl_io = "0.6.0" glutin = { git = "https://github.com/rust-windowing/glutin.git", rev = "07c461e" } [build-dependencies] -cbindgen = "0.18.*" +cbindgen = "0.23.*" [dev-dependencies] -criterion = "0.2" +criterion = "0.3" [[bench]] -name = "benchmarks" +name = "cube" +harness = false + +[[bench]] +name = "benchy" +harness = false + +[[bench]] +name = "shipwreck" harness = false [package.metadata.deb] diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs deleted file mode 100644 index aa71534..0000000 --- a/benches/benchmarks.rs +++ /dev/null @@ -1,53 +0,0 @@ -#[macro_use] -extern crate criterion; -extern crate stl_thumb; - -use criterion::Criterion; -use stl_thumb::config::Config; - -fn cube() { - let config = Config { - stl_filename: "test_data/cube.stl".to_string(), - img_filename: Some("cube.png".to_string()), - width: 1024, - height: 768, - ..Default::default() - }; - - stl_thumb::render_to_file(&config).expect("Error in run function"); -} - -fn benchy() { - let config = Config { - stl_filename: "test_data/3DBenchy.stl".to_string(), - img_filename: Some("benchy.png".to_string()), - width: 1024, - height: 768, - ..Default::default() - }; - - stl_thumb::render_to_file(&config).expect("Error in run function"); -} - - -fn shipwreck() { - let config = Config { - stl_filename: "test_data/shipwreck.stl".to_string(), - img_filename: Some("shipwreck.png".to_string()), - width: 1024, - height: 768, - ..Default::default() - }; - - stl_thumb::render_to_file(&config).expect("Error in run function"); -} - - -fn criterion_benchmark(c: &mut Criterion) { - c.bench_function("cube", |b| b.iter(|| cube())); - c.bench_function("benchy", |b| b.iter(|| benchy())); - c.bench_function("shipwreck", |b| b.iter(|| shipwreck())); -} - -criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); diff --git a/benches/benchy.rs b/benches/benchy.rs new file mode 100644 index 0000000..a0c74b7 --- /dev/null +++ b/benches/benchy.rs @@ -0,0 +1,25 @@ +#[macro_use] +extern crate criterion; +extern crate stl_thumb; + +use criterion::Criterion; +use stl_thumb::config::Config; + +fn benchy() { + let config = Config { + stl_filename: "test_data/3DBenchy.stl".to_string(), + img_filename: "benchy.png".to_string(), + width: 1920, + height: 1080, + ..Default::default() + }; + + stl_thumb::render_to_file(&config).expect("Error in run function"); +} + +fn criterion_benchmark(c: &mut Criterion) { + c.bench_function("benchy", |b| b.iter(|| benchy())); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/benches/cube.rs b/benches/cube.rs new file mode 100644 index 0000000..8f8bb26 --- /dev/null +++ b/benches/cube.rs @@ -0,0 +1,25 @@ +#[macro_use] +extern crate criterion; +extern crate stl_thumb; + +use criterion::Criterion; +use stl_thumb::config::Config; + +fn cube() { + let config = Config { + stl_filename: "test_data/cube.stl".to_string(), + img_filename: "cube.png".to_string(), + width: 1024, + height: 768, + ..Default::default() + }; + + stl_thumb::render_to_file(&config).expect("Error in run function"); +} + +fn criterion_benchmark(c: &mut Criterion) { + c.bench_function("cube", |b| b.iter(|| cube())); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/benches/shipwreck.rs b/benches/shipwreck.rs new file mode 100644 index 0000000..d9c19fb --- /dev/null +++ b/benches/shipwreck.rs @@ -0,0 +1,25 @@ +#[macro_use] +extern crate criterion; +extern crate stl_thumb; + +use criterion::Criterion; +use stl_thumb::config::Config; + +fn shipwreck() { + let config = Config { + stl_filename: "test_data/shipwreck.stl".to_string(), + img_filename: "shipwreck.png".to_string(), + width: 1024, + height: 768, + ..Default::default() + }; + + stl_thumb::render_to_file(&config).expect("Error in run function"); +} + +fn criterion_benchmark(c: &mut Criterion) { + c.bench_function("shipwreck", |b| b.iter(|| shipwreck())); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches);