Skip to content

Commit

Permalink
Added benchmarks for memory and time requirements relative to buildin…
Browse files Browse the repository at this point in the history
…g corpus
  • Loading branch information
LucaCappelletti94 committed Apr 14, 2024
1 parent b6c01fe commit 8afa3f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ In the new edition we also provide a parallel version, which has the same memory
| OLD | 5 | 20,336 | 9,583,720,360 |
| NEW | 6 | 3,893,922 | 615,458,920 |
| NEWPAR | 6 | 163,489 | 615,458,920 |
| OLD | 6 | 22,206 | 10,211,711,214|
| OLD | 6 | 22,206 | 10,211,711,214|ments relative to building corpus)

## Benchmarks 5 April 2024, 08:00 PM
The sixth benchmark was run on a 6-core machine with 32 GBs of RAM. We loaded the entirety of the taxons dataset into memory.
Expand Down
31 changes: 16 additions & 15 deletions benchmarks/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use core::fmt::Debug;
use mem_dbg::*;
use ngrammatic::prelude::*;
use rayon::prelude::*;
use sux::dict::rear_coded_list::{RearCodedList, RearCodedListBuilder};

/// Returns an iterator over the taxons in the corpus.
fn iter_taxons() -> impl Iterator<Item = String> {
Expand Down Expand Up @@ -129,6 +128,10 @@ fn load_corpus_old(arity: usize) -> ngrammatic_old::Corpus {
corpus
}

/// We allow dead code here because the version of the
/// webgraph crate that is necessary for this benchmark
/// is currently in nightly.
#[allow(dead_code)]
fn load_corpus_webgraph<NG>()
where
NG: Ngram<G = ASCIIChar> + Debug,
Expand Down Expand Up @@ -156,6 +159,10 @@ where
);
}

/// We allow dead code here because the version of the
/// webgraph crate that is necessary for this benchmark
/// is currently in nightly.
#[allow(dead_code)]
fn load_corpus_rcl_webgraph<NG>()
where
NG: Ngram<G = ASCIIChar> + Debug,
Expand Down Expand Up @@ -199,18 +206,12 @@ where

fn main() {
env_logger::builder().try_init().unwrap();
// experiment::<UniGram<ASCIIChar>>();
// experiment::<BiGram<ASCIIChar>>();
// experiment::<TriGram<ASCIIChar>>();
// experiment::<TetraGram<ASCIIChar>>();
// experiment::<PentaGram<ASCIIChar>>();
// experiment::<HexaGram<ASCIIChar>>();
// experiment::<HeptaGram<ASCIIChar>>();
// experiment::<OctaGram<ASCIIChar>>();
use ngrammatic::prelude::*;
let mut animals: Vec<String> = iter_taxons().collect();

let corpus: Corpus<Vec<String>, TriGram<char>, Lowercase> = Corpus::par_from(animals);

corpus.mem_dbg(DbgFlags::default() | DbgFlags::CAPACITY | DbgFlags::HUMANIZE).unwrap();
experiment::<UniGram<ASCIIChar>>();
experiment::<BiGram<ASCIIChar>>();
experiment::<TriGram<ASCIIChar>>();
experiment::<TetraGram<ASCIIChar>>();
experiment::<PentaGram<ASCIIChar>>();
experiment::<HexaGram<ASCIIChar>>();
experiment::<HeptaGram<ASCIIChar>>();
experiment::<OctaGram<ASCIIChar>>();
}

0 comments on commit 8afa3f3

Please sign in to comment.