-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
5,997 additions
and
4,929 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
# `webgraph` | ||
# WebGraph | ||
|
||
[![downloads](https://img.shields.io/crates/d/webgraph)](https://crates.io/crates/webgraph) | ||
[![dependents](https://img.shields.io/librariesio/dependents/cargo/webgraph)](https://crates.io/crates/webgraph/reverse_dependencies) | ||
![GitHub CI](https://github.com/vigna/webgraph-rs/actions/workflows/rust.yml/badge.svg) | ||
![license](https://img.shields.io/crates/l/webgraph) | ||
[![](https://tokei.rs/b1/github/vigna/webgraph-rs)](https://github.com/vigna/webgraph-rs). | ||
|
||
A pure Rust implementation of the [WebGraph framework](https://webgraph.di.unimi.it/) for graph compression. | ||
|
||
# Acknowledgments | ||
## Acknowledgments | ||
|
||
This software has been partially supported by project SERICS (PE00000014) under the NRRP MUR program funded by the EU - NGEU, | ||
and by project ANR COREGRAPHIE, grant ANR-20-CE23-0002 of the French Agence Nationale de la Recherche. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Inria | ||
* SPDX-FileCopyrightText: 2023 Sebastiano Vigna | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
*/ | ||
|
||
use std::hint::black_box; | ||
|
||
use anyhow::Result; | ||
use clap::Parser; | ||
use dsi_bitstream::traits::BitRead; | ||
use dsi_bitstream::traits::BitWrite; | ||
use dsi_bitstream::traits::Endianness; | ||
use dsi_progress_logger::*; | ||
use rand::rngs::SmallRng; | ||
use rand::RngCore; | ||
use rand::SeedableRng; | ||
use tempfile::Builder; | ||
use webgraph::prelude::*; | ||
#[derive(Parser, Debug)] | ||
#[command(about = "Tests the merge speed of SortPairs", long_about = None)] | ||
struct Args { | ||
n: usize, | ||
batch: usize, | ||
/// Use 128-bit labels that are neither read nor written. | ||
#[arg(short = 'l', long)] | ||
labeled: bool, | ||
} | ||
|
||
/// No-op serializer/deserializer (as we want to check the merge speed) | ||
#[derive(Debug, Clone)] | ||
struct Mock(); | ||
impl<E: Endianness, W: BitWrite<E>> BitSerializer<E, W> for Mock { | ||
type SerType = u128; | ||
|
||
fn serialize( | ||
&self, | ||
_value: &Self::SerType, | ||
_bitstream: &mut W, | ||
) -> Result<usize, <W as BitWrite<E>>::Error> { | ||
Ok(0) | ||
} | ||
} | ||
impl<E: Endianness, W: BitRead<E>> BitDeserializer<E, W> for Mock { | ||
type DeserType = u128; | ||
|
||
fn deserialize(&self, _bitstream: &mut W) -> Result<Self::DeserType, <W as BitRead<E>>::Error> { | ||
Ok(0) | ||
} | ||
} | ||
|
||
pub fn main() -> Result<()> { | ||
let args = Args::parse(); | ||
|
||
stderrlog::new() | ||
.verbosity(2) | ||
.timestamp(stderrlog::Timestamp::Second) | ||
.init() | ||
.unwrap(); | ||
|
||
let dir = Builder::new().prefix("bench_sort_pairs").tempdir()?; | ||
|
||
if args.labeled { | ||
let mut sp = SortPairs::<Mock, Mock>::new_labeled(args.batch, dir.path(), Mock(), Mock())?; | ||
|
||
let mut r = SmallRng::seed_from_u64(0); | ||
|
||
let mut pl = ProgressLogger::default(); | ||
|
||
pl.start("Writing..."); | ||
for _ in 0..args.n { | ||
sp.push_labeled(r.next_u64() as usize, r.next_u64() as usize, 0)?; | ||
pl.light_update(); | ||
} | ||
pl.done(); | ||
|
||
let mut iter = sp.iter()?; | ||
|
||
pl.start("Reading..."); | ||
for _ in 0..args.n { | ||
black_box(iter.next().unwrap()); | ||
pl.light_update(); | ||
} | ||
pl.done(); | ||
return Ok(()); | ||
} else { | ||
let mut sp = SortPairs::new(args.batch, dir.path())?; | ||
|
||
let mut r = SmallRng::seed_from_u64(0); | ||
|
||
let mut pl = ProgressLogger::default(); | ||
|
||
pl.start("Writing..."); | ||
for _ in 0..args.n { | ||
sp.push(r.next_u64() as usize, r.next_u64() as usize)?; | ||
pl.light_update(); | ||
} | ||
pl.done(); | ||
|
||
let mut iter = sp.iter()?; | ||
|
||
pl.start("Reading..."); | ||
for _ in 0..args.n { | ||
black_box(iter.next().unwrap()); | ||
pl.light_update(); | ||
} | ||
pl.done(); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.