Skip to content

Commit

Permalink
Merge pull request #29 from cooklang/debloat
Browse files Browse the repository at this point in the history
Remove and simplify
  • Loading branch information
Zheoni authored Jan 3, 2025
2 parents bb639e9 + af90b70 commit 18f2db7
Show file tree
Hide file tree
Showing 18 changed files with 761 additions and 535 deletions.
143 changes: 17 additions & 126 deletions Cargo.lock

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

25 changes: 13 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,37 @@ readme = "README.md"

[dependencies]
bitflags = { version = "2", features = ["serde"] }
regex = "1"
serde = { version = "1", features = ["derive", "rc"] }
strum = { version = "0.26.1", features = ["derive"] }
thiserror = "1"
url = { version = "2", features = ["serde"] }
pest = { version = "2", optional = true }
pest_derive = { version = "2", optional = true }
toml = { version = "0.8", optional = true }
once_cell = "1"
thiserror = "2"
enum-map = { version = "2", features = ["serde"] }
tracing = "0.1"
codesnake = "0.2.1"
unicode-width = "0.1.13"
either = "1.8"
unicode-width = "0.2"
finl_unicode = { version = "1.2", features = ["categories"], default-features = false }
smallvec = { version = "1" }
unicase = "2.7.0"
yansi = "1.0.1"
serde_yaml = "0.9.34"

[dev-dependencies]
toml = "0.8"
serde_json = "1"
criterion = "0.5"
test-case = "3.2.1"
indoc = "2.0.3"

[build-dependencies]
toml = { version = "0.8", optional = true }
prettyplease = { version = "0.2", optional = true }
quote = { version = "1", optional = true }
syn = { version = "2", optional = true }
proc-macro2 = { version = "1", optional = true }

[features]
default = ["bundled_units", "aisle"]
bundled_units = ["dep:toml"]
aisle = ["dep:pest", "dep:pest_derive"]
default = ["aisle", "bundled_units"]
bundled_units = ["toml", "prettyplease", "quote", "syn", "proc-macro2"]
aisle = []

[[bench]]
name = "parse"
Expand Down
22 changes: 20 additions & 2 deletions benches/convert.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cooklang::{
convert::{ConvertTo, System},
convert::{ConvertTo, System, UnitsFile},
Converter, Quantity, Value,
};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down Expand Up @@ -43,5 +43,23 @@ fn conversions(c: &mut Criterion) {
});
}

criterion_group!(benches, conversions);
fn bundled_units(c: &mut Criterion) {
let mut group = c.benchmark_group("bundled_units");
group.bench_function("get_bundled", |b| {
b.iter_batched(
|| {},
|_| UnitsFile::bundled(),
criterion::BatchSize::NumIterations((100_000_000 / size_of::<UnitsFile>()) as u64),
);
});
group.bench_function("parse_toml", |b| {
b.iter_batched(
|| {},
|_| toml::from_str::<UnitsFile>(include_str!("../units.toml")),
criterion::BatchSize::NumIterations((100_000_000 / size_of::<UnitsFile>()) as u64),
);
});
}

criterion_group!(benches, conversions, bundled_units);
criterion_main!(benches);
2 changes: 1 addition & 1 deletion bindings/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ trait Amountable {

impl Amountable for OriginalQuantity<OriginalScalableValue> {
fn extract_amount(&self) -> Amount {
let quantity = extract_quantity(&self.value);
let quantity = extract_quantity(self.value());

let units = self.unit().as_ref().map(|u| u.to_string());

Expand Down
Loading

0 comments on commit 18f2db7

Please sign in to comment.