Skip to content

Commit

Permalink
Merge pull request simongog#83 from simongog/YGWYD_rrr_vector
Browse files Browse the repository at this point in the history
Address issue simongog#82 for rrr_vector
  • Loading branch information
simongog committed Sep 11, 2013
2 parents 7196439 + 255f401 commit 2bc7e2f
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 187 deletions.
2 changes: 1 addition & 1 deletion benchmark/rrr_vector/src/generate_rnd_bitvector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main(int argc, char* argv[])
bit_vector v(length);
srand(17);
for (uint64_t i=0; i<v.size(); ++i) {
if (rand()%100 < density) {
if ((uint64_t)(rand()%100) < density) {
v[i] = 1;
}
}
Expand Down
24 changes: 16 additions & 8 deletions benchmark/rrr_vector/src/rrr_time_and_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ using namespace std;
using namespace sdsl;

#ifndef BLOCK_SIZE
#define 31 BLOCK_SIZE
#define BLOCK_SIZE 31
#endif

#ifndef RANK_SAMPLE_DENS
#define RANK_SAMPLE_DENS 32
#endif

using namespace std::chrono;
Expand Down Expand Up @@ -44,21 +48,21 @@ uint64_t test_inv_random_access(const t_vec& v, const int_vector<64>& rands, uin
int main(int argc, char* argv[])
{
if (argc < 3) {
cout << "Usage: " << argv[0] << " bit_vector_file k" << endl;
cout << " generates a rrr_vector<" << BLOCK_SIZE << "> with sample rate k" << endl;
cout << "Usage: " << argv[0] << " bit_vector_file" << endl;
cout << " generates a rrr_vector<" << BLOCK_SIZE << "> with sample rate " << RANK_SAMPLE_DENS << endl;
cout << " for the bitvector stored in bit_vector_file and run a benchmark" << endl;
return 1;
}

typedef rrr_vector<BLOCK_SIZE> rrr_vec_type;
typedef rrr_vector<BLOCK_SIZE, int_vector<>, RANK_SAMPLE_DENS> rrr_vec_type;
typedef rrr_vec_type::select_1_type rrr_select_type;
typedef rrr_vec_type::rank_1_type rrr_rank_type;
bit_vector bv;
if (load_from_file(bv, argv[1])) {
cout << "# plain_size = " << size_in_bytes(bv) << endl;
uint16_t k = atoi(argv[2]);
auto start = timer::now();
rrr_vec_type rrr_vector(bv, k);
rrr_vec_type rrr_vector(bv);
util::clear(bv);
rrr_select_type rrr_sel(&rrr_vector);
rrr_rank_type rrr_rank(&rrr_vector);
Expand All @@ -75,21 +79,25 @@ int main(int argc, char* argv[])
cout << "# btnr_size = " << size_in_bytes(rrr_vector.btnr) << endl;
const uint64_t reps = 10000000;
uint64_t mask = 0;
uint64_t check = 0;
int_vector<64> rands = util::rnd_positions<int_vector<64>>(20, mask, rrr_vector.size(), 17);
start = timer::now();
test_random_access(rrr_vector, rands, mask, reps);
check = test_random_access(rrr_vector, rands, mask, reps);
stop = timer::now();
cout << "# access_time = " << duration_cast<nanoseconds>(stop-start).count()/(double)reps << endl;
cout << "# access_check = " << check << endl;
rands = util::rnd_positions<int_vector<64>>(20, mask, rrr_vector.size()+1, 17);
start = timer::now();
test_inv_random_access(rrr_rank, rands, mask, reps);
check = test_inv_random_access(rrr_rank, rands, mask, reps);
stop = timer::now();
cout << "# rank_time = " << duration_cast<nanoseconds>(stop-start).count()/(double)reps << endl;
cout << "# rank_check = " << check << endl;
rands = util::rnd_positions<int_vector<64>>(20, mask, args, 17);
for (uint64_t i=0; i<rands.size(); ++i) rands[i] = rands[i]+1;
stop = timer::now();
test_inv_random_access(rrr_sel, rands, mask, reps);
check = test_inv_random_access(rrr_sel, rands, mask, reps);
stop = timer::now();
cout << "# select_time = " << duration_cast<nanoseconds>(stop-start).count()/(double)reps << endl;
cout << "# select_check = " << check << endl;
}
}
9 changes: 5 additions & 4 deletions benchmark/rrr_vector/visualize/rrr.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ plot_rrr_space <- function(data, max_y, title="", yaxis=T, xaxis=T, color){
plot_rrr_query_times <- function( data, max_y=NA, title="", yaxis=T, xaxis=T){
cat(title,"\n")
data <- aggregate(data[c('access_time','rank_time','select_time')], by=c(data['K']), FUN=min)
data[c('access_time','rank_time','select_time')] <- data[c('access_time','rank_time','select_time')]/1000.0
data <- data[order(data[['K']]), ]

max_runtime <- max( data[['access_time']], data[['rank_time']], data[['select_time']])*1000
max_runtime <- max( data[['access_time']], data[['rank_time']], data[['select_time']])
if ( !is.na(max_y) ){
max_runtime = max_y
}
Expand All @@ -62,7 +63,7 @@ plot_rrr_query_times <- function( data, max_y=NA, title="", yaxis=T, xaxis=T){
)
box("plot", col="grey")
axis( 1, at = axTicks(1), labels=xaxis, mgp=c(2,0.5,0), tcl=-0.2, cex.axis=1, las=1 )
if ( nr >= xlabnr ){
if ( xaxis ){
xlable <- "Block size K"
mtext(xlable, side=1, line=2, las=0)
}
Expand Down Expand Up @@ -90,7 +91,7 @@ for ( compile_id in compile_config[["COMPILE_ID"]] ){
par(mfrow=c(n/2+1,2))
multi_figure_style( n/2+1, 2 )
nr <- 0
xlabnr <- 2*(n/2)-2
xlabnr <- 2*(n/2)-2+1
for ( tc_id in tc_config[["TC_ID"]] ){
dd <- subset(d, d[["TC_ID"]]==tc_id)
plot_rrr_query_times(dd, 2.1,
Expand Down Expand Up @@ -124,7 +125,7 @@ max_size <- 100*max(d[["rrr_size"]]/d[["plain_size"]])
multi_figure_style( n/2+1, 2 )

nr <- 0
xlabnr <- 2*(n/2)-2
xlabnr <- 2*(n/2)-2+1
colors = c('gray80','gray50','gray30')
for ( tc_id in tc_config[["TC_ID"]] ){
dd <- subset(d, d[["TC_ID"]]==tc_id)
Expand Down
Loading

0 comments on commit 2bc7e2f

Please sign in to comment.