diff --git a/qrcodegen-image/CHANGELOG.md b/qrcodegen-image/CHANGELOG.md index f4b2009..b4d6dfb 100644 --- a/qrcodegen-image/CHANGELOG.md +++ b/qrcodegen-image/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.4.0](https://github.com/constantoine/totp-rs/releases/tag/qrcodegen-image%2Fv1.4.0) (08/03/2024) + +### What's new + +- `draw_canvas` is now 15%(!) faster on my machine after optimizing the "drawing_square" loop. +- Updated `base64` crate to `0.22`. + ## [1.3.0](https://github.com/constantoine/totp-rs/releases/tag/qrcodegen-image%2Fv1.3.0) (19/01/2024) ### What's new diff --git a/qrcodegen-image/Cargo.toml b/qrcodegen-image/Cargo.toml index 9968cc4..dc22dd0 100644 --- a/qrcodegen-image/Cargo.toml +++ b/qrcodegen-image/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "qrcodegen-image" -version = "1.3.0" +version = "1.4.0" edition = "2021" authors = ["Cleo Rebert "] rust-version = "1.61" @@ -19,7 +19,7 @@ base64 = ["dep:base64"] [dependencies] qrcodegen = "1.8" image = { version = "0.24", features = ["png"], default-features = false} -base64 = { version = "0.21", optional = true } +base64 = { version = "0.22.0", optional = true } [dev-dependencies] criterion = { version = "0.5", features = ["html_reports"] } diff --git a/qrcodegen-image/benches/benches.rs b/qrcodegen-image/benches/benches.rs index c29f7fe..c16898c 100644 --- a/qrcodegen-image/benches/benches.rs +++ b/qrcodegen-image/benches/benches.rs @@ -1,6 +1,6 @@ use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; -fn criterion_benchmark(c: &mut Criterion) { +fn canvas_benchmark(c: &mut Criterion) { let input = qrcodegen::QrCode::encode_text("otpauth://totp/GitHub:test?issuer=GitHub&secret=KRSXG5CTMVRXEZLUKN2XAZLSKNSWG4TFOQ&digits=8&period=60&algorithm=SHA256", qrcodegen::QrCodeEcc::Medium).unwrap(); c.bench_with_input( BenchmarkId::new("qrcodegen-image", "draw_canvas"), @@ -13,5 +13,18 @@ fn criterion_benchmark(c: &mut Criterion) { ); } -criterion_group!(benches, criterion_benchmark); +fn png_benchmark(c: &mut Criterion) { + let input = "otpauth://totp/GitHub:test?issuer=GitHub&secret=KRSXG5CTMVRXEZLUKN2XAZLSKNSWG4TFOQ&digits=8&period=60&algorithm=SHA256"; + c.bench_with_input( + BenchmarkId::new("qrcodegen-image", "draw_png"), + black_box(&input), + |b, i| { + b.iter(|| { + let _img = qrcodegen_image::draw_png(i); + }) + }, + ); +} + +criterion_group!(benches, canvas_benchmark, png_benchmark); criterion_main!(benches); diff --git a/qrcodegen-image/src/lib.rs b/qrcodegen-image/src/lib.rs index 8208216..68cbacd 100644 --- a/qrcodegen-image/src/lib.rs +++ b/qrcodegen-image/src/lib.rs @@ -11,22 +11,16 @@ pub fn draw_canvas(qr: qrcodegen::QrCode) -> image::ImageBuffer, Vec image::ImageBuffer, Vec