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

vigna / webgraph-rs / 18008720487

25 Sep 2025 01:16PM UTC coverage: 49.589% (-0.4%) from 49.949%
18008720487

push

github

vigna
Fixed fuzzing code for new epserde

0 of 2 new or added lines in 1 file covered. (0.0%)

650 existing lines in 25 files now uncovered.

3862 of 7788 relevant lines covered (49.59%)

25127316.85 hits per line

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

0.0
/webgraph/examples/bench_unit_transpose.rs
1
/*
2
 * SPDX-FileCopyrightText: 2023 Inria
3
 * SPDX-FileCopyrightText: 2023 Sebastiano Vigna
4
 *
5
 * SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
6
 */
7

8
#![allow(clippy::type_complexity)]
9

10
use std::hint::black_box;
11

12
use anyhow::Result;
13
use clap::Parser;
14
use dsi_bitstream::dispatch::factory::CodesReaderFactoryHelper;
15
use dsi_bitstream::prelude::*;
16
use dsi_progress_logger::prelude::*;
17
use lender::prelude::*;
18
use std::path::PathBuf;
19
use tempfile::Builder;
20
use webgraph::graphs::arc_list_graph::{self, ArcListGraph};
21
use webgraph::{prelude::*, transform};
22

23
#[derive(Parser, Debug)]
24
#[command(about = "Benchmark direct transposition and labeled transposition on a unit graph.", long_about = None)]
25
struct Args {
26
    /// The basename of the graph.
27
    basename: PathBuf,
28
}
29

30
pub fn transpose(
31
    graph: &impl SequentialGraph,
32
    batch_size: usize,
33
) -> Result<Left<ArcListGraph<impl Iterator<Item = (usize, usize, ())> + Clone>>> {
34
    let dir = Builder::new().prefix("bench_unit_transpose").tempdir()?;
35
    let mut sorted = SortPairs::new(batch_size, dir.path())?;
36

37
    let mut pl = ProgressLogger::default();
38
    pl.item_name("node")
39
        .expected_updates(Some(graph.num_nodes()));
40
    pl.start("Creating batches...");
41
    // create batches of sorted edges
42
    for_! ( (src, succ) in graph.iter() {
43
        for dst in succ {
44
            sorted.push(dst, src)?;
45
        }
46
        pl.light_update();
47
    });
48
    // merge the batches
49
    let map: fn((usize, usize, ())) -> (usize, usize) = |(src, dst, _)| (src, dst);
50
    let sorted = arc_list_graph::ArcListGraph::new(graph.num_nodes(), sorted.iter()?.map(map));
51
    pl.done();
52

53
    Ok(sorted)
54
}
55

56
fn bench_impl<E: Endianness>(args: Args) -> Result<()>
57
where
58
    MmapHelper<u32>: CodesReaderFactoryHelper<E>,
59
{
UNCOV
60
    let graph = webgraph::graphs::bvgraph::sequential::BvGraphSeq::with_basename(args.basename)
×
61
        .endianness::<E>()
62
        .load()?;
63

UNCOV
64
    let unit = UnitLabelGraph(&graph);
×
65

UNCOV
66
    for _ in 0..10 {
×
67
        let mut pl = ProgressLogger::default();
×
68
        pl.start("Transposing standard graph...");
×
69

UNCOV
70
        let mut iter = transpose(&graph, 10_000_000)?.iter();
×
71
        while let Some((x, s)) = iter.next() {
×
72
            black_box(x);
×
73
            for i in s {
×
74
                black_box(i);
×
75
            }
76
        }
UNCOV
77
        pl.done_with_count(graph.num_nodes());
×
78

UNCOV
79
        pl.start("Transposing unit graph...");
×
80
        let mut iter = Left(transform::transpose_labeled(&unit, 10_000_000, (), ())?).iter();
×
81
        while let Some((x, s)) = iter.next() {
×
82
            black_box(x);
×
83
            for i in s {
×
84
                black_box(i);
×
85
            }
86
        }
UNCOV
87
        pl.done_with_count(unit.num_nodes());
×
88
    }
89

UNCOV
90
    Ok(())
×
91
}
92

93
pub fn main() -> Result<()> {
94
    let args = Args::parse();
95

96
    env_logger::builder()
97
        .filter_level(log::LevelFilter::Info)
98
        .try_init()?;
99

100
    match get_endianness(&args.basename)?.as_str() {
101
        #[cfg(any(
102
            feature = "be_bins",
103
            not(any(feature = "be_bins", feature = "le_bins"))
104
        ))]
105
        BE::NAME => bench_impl::<BE>(args),
106
        #[cfg(any(
107
            feature = "le_bins",
108
            not(any(feature = "be_bins", feature = "le_bins"))
109
        ))]
110
        LE::NAME => bench_impl::<LE>(args),
111
        e => panic!("Unknown endianness: {}", e),
112
    }
113
}
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