#include #include #include #include #include #include // enable debugging code in spp_bitset.h #define SPP_TEST 1 #include #include #include using namespace std; // ----------------------------------------------------------- // ----------------------------------------------------------- template class TestBitset { public: typedef spp::spp_bitset BS; TestBitset() {} void test_set(size_t num_iter) { size_t num_errors = 0; BS bs, bs2; printf("testing set on spp_bitset<%zu> , num_iter=%6zu -> ", N, num_iter); for (size_t i=0; i, num_iter=%6zu -> ", N, num_iter); for (size_t i=0; i, num_iter=%6zu -> ", N, num_iter); for (size_t i=0; i<4 * N; ++i) { bs.set(rand() % N); if (i > 2 * N) { for (size_t j=0; j, num_iter=%6zu -> ", N, num_iter); for (size_t i=0; i 1000) { bs.set(1000); size_t longest = bs.longest_zero_sequence(); assert(longest == 1000-11 || longest == N-1001); if (!(longest == 1000-11 || longest == N-1001)) ++num_errors; } spp::Timer timer_lz; spp::Timer timer_lz_slow; float lz_time(0), lz_time_slow(0); printf("testing longest_zero_sequence() , num_iter=%6zu -> ", num_iter); srand(1); for (size_t i=0; i 1000) { bs.set(1000); size_t longest = bs.longest_zero_sequence(); assert(longest == 1000-11 || longest == N-1001); if (!(longest == 1000-11 || longest == N-1001)) ++num_errors; } spp::Timer timer_lz; spp::Timer timer_lz_slow; float lz_time(0), lz_time_slow(0); printf("testing longest_zero_sequence2() , num_iter=%6zu -> ", num_iter); srand(1); for (size_t i=0; i timer_ctz; spp::Timer timer_ctz_slow; float ctz_time(0), ctz_time_slow(0); printf("testing count_trailing_zeroes() , num_iter=%6zu -> ", num_iter); for (size_t i=0; i test_bitset_1024; test_bitset_1024.run(); TestBitset<4096> test_bitset_4096; test_bitset_4096.run(); //TestBitset<8192> test_bitset_8192; //test_bitset_8192.run(); }