Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce ProguardCache format #42

Merged
merged 24 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ edition = "2018"
uuid = ["uuid_", "lazy_static"]

[dependencies]
uuid_ = { package = "uuid", version = "1.0.0", features = ["v5"], optional = true }
lazy_static = { version = "1.4.0", optional = true }
thiserror = "1.0.61"
uuid_ = { package = "uuid", version = "1.0.0", features = ["v5"], optional = true }
loewenheim marked this conversation as resolved.
Show resolved Hide resolved
watto = { version = "0.1.0", features = ["writer", "strings"] }

[dev-dependencies]
lazy_static = "1.4.0"
Expand All @@ -24,3 +26,7 @@ criterion = "0.4"
[[bench]]
name = "proguard_parsing"
harness = false

[[bench]]
name = "proguard_mapping"
harness = false
40 changes: 40 additions & 0 deletions benches/proguard_mapping.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use proguard::{ProguardCache, ProguardMapper, ProguardMapping};

static MAPPING: &[u8] = include_bytes!("../tests/res/mapping-inlines.txt");

static RAW: &str = r#"java.lang.RuntimeException: Button press caused an exception!
at io.sentry.sample.MainActivity.t(MainActivity.java:1)
at e.a.c.a.onClick
at android.view.View.performClick(View.java:7125)
at android.view.View.performClickInternal(View.java:7102)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27336)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)"#;

fn benchmark_remapping(c: &mut Criterion) {
let mut cache = Vec::new();
let mapping = ProguardMapping::new(MAPPING);
ProguardCache::write(&mapping, &mut cache).unwrap();
let cache = ProguardCache::parse(&cache).unwrap();
let mapper = ProguardMapper::new(mapping);

let mut group = c.benchmark_group("Proguard Remapping");

group.bench_function("Cache", |b| {
b.iter(|| cache.remap_stacktrace(black_box(RAW)))
});
group.bench_function("Mapper", |b| {
b.iter(|| mapper.remap_stacktrace(black_box(RAW)))
});
loewenheim marked this conversation as resolved.
Show resolved Hide resolved
group.finish();
}

criterion_group!(benches, benchmark_remapping);
criterion_main!(benches);
Loading
Loading