Skip to content

Commit

Permalink
bench: Add other X.509 libraries to bench
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed Oct 24, 2024
1 parent 82ea031 commit d90deee
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 9 deletions.
214 changes: 214 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,7 @@ iai = "0.1.1"
once_cell = "1.20.2"
pretty_assertions.workspace = true
rasn-pkix = { path = "standards/pkix" }
rustls-webpki = "0.102.8"
x509-cert = "0.2.5"
x509-certificate = "0.23.1"
x509-parser = "0.16"
20 changes: 11 additions & 9 deletions benches/criterion.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
//! Port of the `asn1tools` benchmark in Rust.

mod common;

use criterion::{black_box, criterion_group, criterion_main, Criterion};

use common::*;

fn asn1tools(c: &mut Criterion) {
fn rasn(c: &mut Criterion) {
let decoded = black_box(bench_default());

macro_rules! bench_encoding_rules {
Expand All @@ -25,18 +23,22 @@ fn asn1tools(c: &mut Criterion) {
}

fn x509(c: &mut Criterion) {
use x509_parser::prelude::*;

let data: &[u8] = include_bytes!("../standards/pkix/tests/data/letsencrypt-x3.crt");
let mut group = c.benchmark_group("Certificate");
let mut group = c.benchmark_group("X.509");
group.bench_function("rasn", |b| {
b.iter(|| black_box(rasn::der::decode::<rasn_pkix::Certificate>(data).unwrap()))
});
group.bench_function("x509_parser", |b| {
b.iter(|| black_box(X509Certificate::from_der(data)))
group.bench_function("x509-parser", |b| {
b.iter(|| black_box(<x509_parser::certificate::X509Certificate as x509_parser::prelude::FromDer<x509_parser::error::X509Error>>::from_der(data)))
});
group.bench_function("x509-cert", |b| {
b.iter(|| black_box(<x509_cert::Certificate as x509_cert::der::Decode>::from_der(data)))
});
group.bench_function("x509-certificate", |b| {
b.iter(|| black_box(x509_certificate::X509Certificate::from_der(data)))
});
group.finish();
}

criterion_group!(codec, x509, asn1tools);
criterion_group!(codec, x509, rasn);
criterion_main!(codec);

0 comments on commit d90deee

Please sign in to comment.