-
Notifications
You must be signed in to change notification settings - Fork 10
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
7 changed files
with
51 additions
and
48 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
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,32 +1,30 @@ | ||
use succinct::{rank, select::{Select0Support, Select1Support}, BinSearchSelect, BitRankSupport, BitVecMut, BitVector, SpaceUsage}; | ||
use crate::{percent_of_diff, Conf, Tester}; | ||
use crate::{Conf, Tester}; | ||
|
||
pub fn build_bit_vec(conf: &Conf) -> (BitVector::<u64>, Tester) { | ||
let mut content = BitVector::with_fill(conf.universe as u64, false); | ||
let tester = conf.fill_data(|bit_nr, value| {content.set_bit(bit_nr as u64, value)}); | ||
(content, tester) | ||
} | ||
|
||
fn benchmark(mut tester: super::Tester, method_name: &str, content_size: usize, rank: impl BitRankSupport+SpaceUsage) { | ||
fn benchmark(mut tester: super::Tester, method_name: &str, rank: impl BitRankSupport+SpaceUsage) { | ||
tester.rank_includes_current = true; | ||
tester.raport_rank(method_name, percent_of_diff(rank.total_bytes(), content_size), | ||
tester.raport_rank(method_name, rank.total_bytes(), | ||
|index| rank.rank1(index as u64) as usize); | ||
println!(" select by binary search over ranks (no extra space overhead):"); | ||
let select = BinSearchSelect::new(rank); | ||
tester.raport_select1(method_name, 0.0, |index| select.select1(index as u64).map(|v| v as usize)); | ||
tester.raport_select0(method_name, 0.0, |index| select.select0(index as u64).map(|v| v as usize)); | ||
tester.raport_select1(method_name, 0, |index| select.select1(index as u64).map(|v| v as usize)); | ||
tester.raport_select0(method_name, 0, |index| select.select0(index as u64).map(|v| v as usize)); | ||
} | ||
|
||
pub fn benchmark_rank9(conf: &super::Conf) { | ||
println!("succinct Rank9:"); | ||
let (content, tester) = build_bit_vec(conf); | ||
benchmark(tester, "succinct Rank9", content.total_bytes(), | ||
rank::Rank9::new(content)); | ||
benchmark(tester, "succinct Rank9", rank::Rank9::new(content)); | ||
} | ||
|
||
pub fn benchmark_jacobson(conf: &super::Conf) { | ||
println!("succinct JacobsonRank:"); | ||
let (content, tester) = build_bit_vec(conf); | ||
benchmark(tester, "succinct JacobsonRank", content.total_bytes(), | ||
rank::JacobsonRank::new(content)); | ||
benchmark(tester, "succinct JacobsonRank", rank::JacobsonRank::new(content)); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
use vers_vecs::{BitVec, RsVec}; | ||
use crate::percent_of_diff; | ||
|
||
pub fn benchmark_rank_select(conf: &super::Conf) { | ||
println!("vers:"); | ||
let mut content = BitVec::from_zeros(conf.universe); | ||
let tester = conf.fill_data(|pos, value| if value { content.flip_bit(pos); }); | ||
|
||
let raw_size = content.heap_size(); | ||
let rs = RsVec::from_bit_vec(content); | ||
tester.raport_rank("vers RsVec", percent_of_diff(rs.heap_size(), raw_size), |index| rs.rank1(index)); | ||
tester.raport_select1("vers RsVec", 0.0, |index| rs.select1(index)); | ||
tester.raport_select0("vers RsVec", 0.0, |index| rs.select0(index)); | ||
tester.raport_rank("vers RsVec", rs.heap_size(), |index| rs.rank1(index)); | ||
tester.raport_select1("vers RsVec", 0, |index| rs.select1(index)); | ||
tester.raport_select0("vers RsVec", 0, |index| rs.select0(index)); | ||
} | ||
|