+12
-6
benches/non-huge-cars.rs
+12
-6
benches/non-huge-cars.rs
···
3
3
use iroh_car::CarReader;
4
4
use std::convert::Infallible;
5
5
6
-
use criterion::{criterion_group, criterion_main, Criterion};
6
+
use criterion::{Criterion, criterion_group, criterion_main};
7
7
8
8
const TINY_CAR: &'static [u8] = include_bytes!("../car-samples/tiny.car");
9
9
const LITTLE_CAR: &'static [u8] = include_bytes!("../car-samples/little.car");
···
15
15
.build()
16
16
.expect("Creating runtime failed");
17
17
18
-
c.bench_function("tiny-car", |b| b.to_async(&rt).iter(async || drive_car(TINY_CAR).await ));
19
-
c.bench_function("little-car", |b| b.to_async(&rt).iter(async || drive_car(LITTLE_CAR).await ));
20
-
c.bench_function("midsize-car", |b| b.to_async(&rt).iter(async || drive_car(MIDSIZE_CAR).await ));
18
+
c.bench_function("tiny-car", |b| {
19
+
b.to_async(&rt).iter(async || drive_car(TINY_CAR).await)
20
+
});
21
+
c.bench_function("little-car", |b| {
22
+
b.to_async(&rt).iter(async || drive_car(LITTLE_CAR).await)
23
+
});
24
+
c.bench_function("midsize-car", |b| {
25
+
b.to_async(&rt).iter(async || drive_car(MIDSIZE_CAR).await)
26
+
});
21
27
}
22
28
23
29
async fn drive_car(bytes: &[u8]) {
···
27
33
.header()
28
34
.roots()
29
35
.first()
30
-
.ok_or("missing root").unwrap()
36
+
.ok_or("missing root")
37
+
.unwrap()
31
38
.clone();
32
39
33
40
let stream = std::pin::pin!(reader.stream());
···
45
52
46
53
criterion_group!(benches, criterion_benchmark);
47
54
criterion_main!(benches);
48
-
+2
-2
tests/non-huge-cars.rs
+2
-2
tests/non-huge-cars.rs
···
7
7
const LITTLE_CAR: &'static [u8] = include_bytes!("../car-samples/little.car");
8
8
const MIDSIZE_CAR: &'static [u8] = include_bytes!("../car-samples/midsize.car");
9
9
10
-
11
10
async fn test_car(bytes: &[u8], expected_records: usize, expected_sum: usize) {
12
11
let reader = CarReader::new(bytes).await.unwrap();
13
12
···
15
14
.header()
16
15
.roots()
17
16
.first()
18
-
.ok_or("missing root").unwrap()
17
+
.ok_or("missing root")
18
+
.unwrap()
19
19
.clone();
20
20
21
21
let stream = std::pin::pin!(reader.stream());