Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
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 verifyBehaviour ()
 
template<typename I >
void verifyIntegerTypes ()
 
void runPerformanceTest ()
 

Member Function Documentation

◆ run()

virtual void run ( Arg  arg)
inlineprivatevirtual

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

References util::isnil(), UtilFloordiv_test::runPerformanceTest(), and UtilFloordiv_test::verifyBehaviour().

+ Here is the call graph for this function:

◆ verifyBehaviour()

void verifyBehaviour ( )
inlineprivate

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

References util::floordiv().

Referenced by UtilFloordiv_test::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verifyIntegerTypes()

template<typename I >
void verifyIntegerTypes ( )
inlineprivate

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

References util::floordiv().

+ Here is the call graph for this function:

◆ 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.

References DISPLAY_TIMINGS, util::floordiv(), and START_TIMINGS.

Referenced by UtilFloordiv_test::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:
+ Inheritance diagram for UtilFloordiv_test:
+ Collaboration diagram for UtilFloordiv_test:

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