X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Ftests%2Fstatic_bitsequence_test.cpp;fp=libcds%2Ftests%2Fstatic_bitsequence_test.cpp;h=9fc08f004af7360a40d45b213264b3d3e7981742;hb=52cb7bbcda67f4676335cdd4eb96d4d87ad1445d;hp=0000000000000000000000000000000000000000;hpb=950870fc762cf5c4d551db78bc798b540d893b4a;p=SXSI%2FXMLTree.git diff --git a/libcds/tests/static_bitsequence_test.cpp b/libcds/tests/static_bitsequence_test.cpp new file mode 100644 index 0000000..9fc08f0 --- /dev/null +++ b/libcds/tests/static_bitsequence_test.cpp @@ -0,0 +1,71 @@ +/* static_bitsequence_test.cpp + * Copyright (C) 2008, Francisco Claude, all rights reserved. + * + * static_bitsequence_test + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include +#include "static_bitsequence_tester.h" + +using namespace std; + +int main(int argc, char ** argv) { + if(argc!=5) { + cout << "usage: " << argv[0] << " " << endl; + return 0; + } + FILE * fp = fopen(argv[1],"r"); + if(fp==NULL) { + cout << "Error opening " << argv[1] << endl; + return -1; + } + uint *bitseq, len;//, ones; + uint l=fread(&len, sizeof(uint), 1, fp); + //l += fread(&ones,sizeof(uint),1,fp); + bitseq = new uint[uint_len(len,1)]; + l+=fread(bitseq, sizeof(uint), uint_len(len,1), fp); + fclose(fp); + + uint sample_rate; + stringstream ss(argv[3]); + ss >> sample_rate; + + static_bitsequence * bs; + + if(string(argv[2])==string("r")) bs = new static_bitsequence_rrr02(bitseq,len,sample_rate); + else bs = new static_bitsequence_brw32(bitseq,len,sample_rate); + + cout << "Size: " << bs->size() << endl; + cout << "bpb = " << bs->size()*8./len << endl; + + if(string(argv[4])==string("t")) + test_bitsequence(bitseq,len,bs); + cout << "******************************************" << endl; + speed_access(bs, bitseq, len); + cout << "******************************************" << endl; + speed_rank0(bs, bitseq, len); + cout << "******************************************" << endl; + speed_rank1(bs, bitseq, len); + cout << "******************************************" << endl; + speed_select0(bs, bitseq, len); + cout << "******************************************" << endl; + speed_select1(bs, bitseq, len); +}