Lumiera  0.pre.03
»edit your freedom«
UtilFloordiv_test Class Reference

Description

Test:
Evaluate a custom built integer floor function.

Also known as Knuth's floor division. This function is crucial for Lumiera's rule of quantisation of time values into frame intervals. This rule requires time points to be rounded towards the next lower frame border always, irrespective of the relation to the actual time origin. Contrast this to the built-in integer division operator, which truncates towards zero.

Note
if invoked with an non empty parameter, this test performs some interesting timing comparisons, which initially were used to tweak the implementation a bit.
See also
lib/util.hpp
QuantiserBasics_test

Definition at line 103 of file util-floordiv-test.cpp.

Private Member Functions

virtual void run (Arg arg)
 
void runPerformanceTest ()
 
void verifyBehaviour ()
 
template<typename I >
void verifyIntegerTypes ()
 

Member Function Documentation

◆ runPerformanceTest()

void runPerformanceTest ( )
inlineprivate
Test:
timing measurements to compare implementation details.

This test uses a sequence of random integers, where the values used as denominator are ensured not to be zero.

measurement results
My experiments (AMD Athlon-64 4200 X2) gave me the following timing measurements in nanoseconds:

Verification.......... 127.7 Integer_div........... 111.7 double_floor.......... 74.8 floordiv_int.......... 112.7 floordiv_long......... 119.8 floordiv_int64_t...... 121.4 floordiv_long_alt..... 122.7

These figures are the average of 6 runs with 50 million iterations each (as produced by this function)

conclusions
The most significant result is the striking performance of the fpu based calculation. Consequently, integer arithmetics should only be used when necessary due to resolution requirements, as is the case for int64_t based Lumiera Time values, which require a precision beyond the 16 digits provided by double. Besides that, we can conclude that the additional tests and adjustment of the custom floordiv only creates a slight overhead compared to the built-in integer div function. An oddity to note is the slightly better performance of long over int64_t. Also, the alternative formulation of the function, which uses the fdiv() function also to divide the positive results, performs only slightly worse. So this implementation was chosen mainly because it seems to state its intent more clearly in code.

Definition at line 208 of file util-floordiv-test.cpp.

+ Inheritance diagram for UtilFloordiv_test:
+ Collaboration diagram for UtilFloordiv_test:

The documentation for this class was generated from the following file: