forked from GitoxideLabs/gitoxide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode_objects.rs
More file actions
36 lines (31 loc) · 1.41 KB
/
decode_objects.rs
File metadata and controls
36 lines (31 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use criterion::{criterion_group, criterion_main, Criterion};
use std::hint::black_box;
fn parse_commit(c: &mut Criterion) {
c.bench_function("CommitRef(sig)", |b| {
b.iter(|| black_box(gix_object::CommitRef::from_bytes(COMMIT_WITH_MULTI_LINE_HEADERS)).unwrap());
});
c.bench_function("CommitRefIter(sig)", |b| {
b.iter(|| black_box(gix_object::CommitRefIter::from_bytes(COMMIT_WITH_MULTI_LINE_HEADERS).count()));
});
}
fn parse_tag(c: &mut Criterion) {
c.bench_function("TagRef(sig)", |b| {
b.iter(|| black_box(gix_object::TagRef::from_bytes(TAG_WITH_SIGNATURE)).unwrap());
});
c.bench_function("TagRefIter(sig)", |b| {
b.iter(|| black_box(gix_object::TagRefIter::from_bytes(TAG_WITH_SIGNATURE).count()));
});
}
fn parse_tree(c: &mut Criterion) {
c.bench_function("TreeRef()", |b| {
b.iter(|| black_box(gix_object::TreeRef::from_bytes(TREE)).unwrap());
});
c.bench_function("TreeRefIter()", |b| {
b.iter(|| black_box(gix_object::TreeRefIter::from_bytes(TREE).count()));
});
}
criterion_group!(benches, parse_commit, parse_tag, parse_tree);
criterion_main!(benches);
const COMMIT_WITH_MULTI_LINE_HEADERS: &[u8] = include_bytes!("../tests/fixtures/commit/two-multiline-headers.txt");
const TAG_WITH_SIGNATURE: &[u8] = include_bytes!("../tests/fixtures/tag/signed.txt");
const TREE: &[u8] = include_bytes!("../tests/fixtures/tree/everything.tree");