• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cookiephone / libnoise-rs / #39

28 Apr 2025 08:21AM UTC coverage: 89.343% (-4.1%) from 93.457%
#39

push

web-flow
Merge pull request #16 from cookiephone/2024edition

update rust edition to 2024

64 of 67 new or added lines in 7 files covered. (95.52%)

46 existing lines in 6 files now uncovered.

1006 of 1126 relevant lines covered (89.34%)

549094.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/devtools/benchtools.rs
1
use crate::Generator;
2
use criterion::{Criterion, black_box};
3
use itertools::Itertools;
4

5
pub fn bench_noise1d<G: Generator<1>>(
×
6
    c: &mut Criterion,
7
    id: &str,
8
    shape: &[usize],
9
    scale: f64,
10
    generator: &G,
11
) {
12
    c.bench_function(id, |b| {
×
13
        b.iter(|| noise_bencher::<1, _>(generator, shape, scale));
×
14
    });
15
}
16

17
pub fn bench_noise2d<G: Generator<2>>(
×
18
    c: &mut Criterion,
19
    id: &str,
20
    shape: &[usize],
21
    scale: f64,
22
    generator: &G,
23
) {
24
    c.bench_function(id, |b| {
×
25
        b.iter(|| noise_bencher::<2, _>(generator, shape, scale));
×
26
    });
27
}
28

29
pub fn bench_noise3d<G: Generator<3>>(
×
30
    c: &mut Criterion,
31
    id: &str,
32
    shape: &[usize],
33
    scale: f64,
34
    generator: &G,
35
) {
36
    c.bench_function(id, |b| {
×
37
        b.iter(|| noise_bencher::<3, _>(generator, shape, scale));
×
38
    });
39
}
40

41
pub fn bench_noise4d<G: Generator<4>>(
×
42
    c: &mut Criterion,
43
    id: &str,
44
    shape: &[usize],
45
    scale: f64,
46
    generator: &G,
47
) {
48
    c.bench_function(id, |b| {
×
49
        b.iter(|| noise_bencher::<4, _>(generator, shape, scale));
×
50
    });
51
}
52

53
fn noise_bencher<const D: usize, G: Generator<D>>(generator: &G, shape: &[usize], scale: f64) {
×
54
    for point in cartesian_lattice_points(shape, scale) {
×
55
        black_box(generator.sample(black_box(point.try_into().unwrap())));
×
56
    }
57
}
58

NEW
59
fn tensor_indices(shape: &[usize]) -> impl Iterator<Item = Vec<usize>> + use<> {
×
60
    shape
×
61
        .iter()
62
        .map(|&dim_size| 0..dim_size)
×
63
        .multi_cartesian_product()
64
}
65

NEW
66
fn cartesian_lattice_points(shape: &[usize], scale: f64) -> impl Iterator<Item = Vec<f64>> + use<> {
×
67
    tensor_indices(shape).map(move |point| {
×
68
        point
×
69
            .iter()
×
70
            .map(|&component| component as f64 * scale)
×
71
            .collect()
×
72
    })
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc