1 /* static_bitsequence_test.cpp
2 * Copyright (C) 2008, Francisco Claude, all rights reserved.
4 * static_bitsequence_test
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <static_bitsequence.h>
26 #include "static_bitsequence_tester.h"
30 int main(int argc, char ** argv) {
32 cout << "usage: " << argv[0] << " <bitmap_file> <b|r> <sample_rate> <t|s>" << endl;
35 FILE * fp = fopen(argv[1],"r");
37 cout << "Error opening " << argv[1] << endl;
40 uint *bitseq, len;//, ones;
41 uint l=fread(&len, sizeof(uint), 1, fp);
42 //l += fread(&ones,sizeof(uint),1,fp);
43 bitseq = new uint[uint_len(len,1)];
44 l+=fread(bitseq, sizeof(uint), uint_len(len,1), fp);
48 stringstream ss(argv[3]);
51 static_bitsequence * bs;
53 if(string(argv[2])==string("r")) bs = new static_bitsequence_rrr02(bitseq,len,sample_rate);
54 else bs = new static_bitsequence_brw32(bitseq,len,sample_rate);
56 cout << "Size: " << bs->size() << endl;
57 cout << "bpb = " << bs->size()*8./len << endl;
59 if(string(argv[4])==string("t"))
60 test_bitsequence(bitseq,len,bs);
61 cout << "******************************************" << endl;
62 speed_access(bs, bitseq, len);
63 cout << "******************************************" << endl;
64 speed_rank0(bs, bitseq, len);
65 cout << "******************************************" << endl;
66 speed_rank1(bs, bitseq, len);
67 cout << "******************************************" << endl;
68 speed_select0(bs, bitseq, len);
69 cout << "******************************************" << endl;
70 speed_select1(bs, bitseq, len);