Skip to content

Commit

Permalink
test: add simple benchmarks using divan
Browse files Browse the repository at this point in the history
  • Loading branch information
zbrox committed Jan 30, 2024
1 parent 30f7638 commit f402e45
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ serde = { version = "1.0.127", optional = true, features = ["derive"] }
strum = {version = "0.25.0", optional = true, features = ["derive"] }

[dev-dependencies]
divan = "0.1.11"
serde_json = "1.0.66"

[build-dependencies]
Expand All @@ -31,3 +32,7 @@ quote = "1.0.35"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[[bench]]
name = "parse"
harness = false
21 changes: 21 additions & 0 deletions benches/parse.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use std::str::FromStr;

fn main() {
// Run registered benchmarks.
divan::main();
}

#[divan::bench]
fn parse_code() {
iso_currency::Currency::from_code("EUR").unwrap();
}

#[divan::bench]
fn parse_numeric() {
iso_currency::Currency::from_numeric(978).unwrap();
}

#[divan::bench]
fn from_str() {
iso_currency::Currency::from_str("SEK").unwrap();
}

0 comments on commit f402e45

Please sign in to comment.