12 changes: 6 additions & 6 deletions performance/performance_test.cpp
Expand Up @@ -294,25 +294,25 @@ struct tester
}
double test_left_shift()
{
int shift = std::numeric_limits<T>::is_bounded ? std::numeric_limits<T>::digits : bits_wanted;
shift /= 2;
int max_shift = std::numeric_limits<T>::is_bounded ? std::numeric_limits<T>::digits : bits_wanted;
int shift = 0;
stopwatch<boost::chrono::high_resolution_clock> w;
for(unsigned i = 0; i < 1000; ++i)
{
for(unsigned i = 0; i < b.size(); ++i)
a[i] = b[i] << shift;
a[i] = b[i] << (shift++ % max_shift);
}
return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count();
}
double test_right_shift()
{
int shift = std::numeric_limits<T>::is_bounded ? std::numeric_limits<T>::digits : bits_wanted;
shift /= 2;
int max_shift = 2 + std::numeric_limits<T>::is_bounded ? std::numeric_limits<T>::digits : bits_wanted;
int shift = 0;
stopwatch<boost::chrono::high_resolution_clock> w;
for(unsigned i = 0; i < 1000; ++i)
{
for(unsigned i = 0; i < b.size(); ++i)
a[i] = b[i] >> shift;
a[i] = b[i] >> (shift++) % max_shift;
}
return boost::chrono::duration_cast<boost::chrono::duration<double> >(w.elapsed()).count();
}
Expand Down
6 changes: 6 additions & 0 deletions test/test_cpp_int.cpp
Expand Up @@ -11,6 +11,12 @@
# define _SCL_SECURE_NO_WARNINGS
#endif

//
// This ensures all our code gets tested, even though it may
// not be the fastest configuration in normal use:
//
#define BOOST_MP_USE_LIMB_SHIFT

#include <boost/multiprecision/gmp.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/random/mersenne_twister.hpp>
Expand Down