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

Fix benchmarks for MacOS #7

Merged
merged 2 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions .github/workflows/rust-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
sudo apt-get install libeccodes-dev
rustup update stable
cargo clean
- name: Build with cargo
- name: Test with cargo
run: |
cargo build --release
RUST_BACKTRACE=full cargo test
- name: Check with clippy
run: |
cargo clippy -- -W clippy::pedantic
- name: Test with cargo
- name: Build release
run: |
cargo test
cargo build --release

build-macos:

Expand All @@ -43,12 +43,12 @@ jobs:
brew install eccodes
rustup update stable
cargo clean
- name: Build with cargo
- name: Test with cargo
run: |
cargo build --release
RUST_BACKTRACE=full cargo test
- name: Check with clippy
run: |
cargo clippy -- -W clippy::pedantic
- name: Test with cargo
- name: Build release
run: |
cargo test
cargo build --release
2 changes: 1 addition & 1 deletion benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn key_reading(c: &mut Criterion) {
});

c.bench_function("bytes reading", |b| {
b.iter(|| msg.read_key(black_box("mybits")).unwrap())
b.iter(|| msg.read_key(black_box("section1Padding")).unwrap())
});

c.bench_function("missing nul-byte termination reading", |b| {
Expand Down
20 changes: 20 additions & 0 deletions src/codes_handle/keyed_message/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,24 @@ mod tests {

assert!(missing_key.is_err());
}

#[test]
fn benchmark_keys() {
let file_path = Path::new("./data/iceland.grib");
let product_kind = ProductKind::GRIB;

let mut handle = CodesHandle::new_from_file(file_path, product_kind).unwrap();

let msg = handle.next().unwrap().unwrap();

let _ = msg.read_key("dataDate").unwrap();
let _ = msg.read_key("jDirectionIncrementInDegrees").unwrap();
let _ = msg.read_key("values").unwrap();
let _ = msg.read_key("name").unwrap();
let _ = msg.read_key("section1Padding").unwrap();
let _ = msg.read_key("experimentVersionNumber").unwrap();
let _ = msg
.read_key("zero")
.unwrap_or_else(|_| msg.read_key("zeros").unwrap());
}
}