45 typedef std::vector<int>
VecI;
51 for (
uint i=0; i<cnt; ++i)
56 data.push_back (someNumber);
78 ldiv_t res = ldiv(num,den);
79 return (0 >= res.quot and res.rem)? res.quot-1
113 verifyIntegerTypes<int>();
114 verifyIntegerTypes<long>();
115 verifyIntegerTypes<short>();
116 verifyIntegerTypes<int64_t>();
117 verifyIntegerTypes<llong>();
161 for (
int i=-12; i <= 12; ++i)
166 CHECK (
floordiv(n,d) == expectedRes);
210 VecI testdata = buildTestNumberz (2*NUM_ELMS_PERFORMANCE_TEST);
211 typedef VecI::const_iterator I;
213 clock_t start(0), stop(0);
214 _Fmt resultDisplay{
"timings(%s)%|30T.|%5.3fsec\n"};
216#define START_TIMINGS start=clock();
217#define DISPLAY_TIMINGS(ID) \
219 cout << resultDisplay % STRINGIFY (ID) % (double(stop-start)/CLOCKS_PER_SEC) ;
222 for (I ii =testdata.begin(); ii!=testdata.end(); )
228 CHECK (floor(
double(num)/den) ==
floordiv(num,den));
233 for (I ii =testdata.begin(); ii!=testdata.end(); )
235 integerDiv (*ii++, *ii++);
240 for (I ii =testdata.begin(); ii!=testdata.end(); )
242 floor (
double(*ii++) / *ii++);
247 for (I ii =testdata.begin(); ii!=testdata.end(); )
254 for (I ii =testdata.begin(); ii!=testdata.end(); )
256 floordiv (
long(*ii++),
long(*ii++));
261 for (I ii =testdata.begin(); ii!=testdata.end(); )
263 floordiv (int64_t(*ii++), int64_t(*ii++));
268 for (I ii =testdata.begin(); ii!=testdata.end(); )
270 floordiv_alternate (*ii++, *ii++);
A front-end for using printf-style formatting.
void runPerformanceTest()
virtual void run(Arg arg)
void verifyIntegerTypes()
#define DISPLAY_TIMINGS(ID)
Test runner and basic definitions for tests.
long integerDiv(long num, long den)
the built-in integer division operator, packaged as inline function for timing comparison
long floordiv_alternate(long num, long den)
an alternate formulation, which turned out to perform slightly worse
VecI buildTestNumberz(uint cnt)
const uint NUM_ELMS_PERFORMANCE_TEST
I floordiv(I num, I den)
floor function for integer arithmetics.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Utilities for quantisation (grid alignment) and comparisons.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...