#ifndef TEST_SUITE_T #define TEST_SUITE_T /** * Calculates the Fibonacci-Number recursively * @param n The n'th fibonacci-number to calculate (must be positive) * @return The n'th fibonacci-number. Undefined behaviour when a negative *n* was supplied. */ int fiborec(int n); /** * Calculates the Fibonacci-Number iteratively * @param n The n'th fibonacci-number to calculate (must be positive) * @return The n'th fibonacci-number. Undefined behaviour when a negative *n* was supplied. */ int fiboiter(int n); /** * Calculates the Fibonacci-Number recursively while using a cache to store previous values. * @param n The n'th fibonacci-number to calculate (must be positive) * @return The n'th fibonacci-number. Undefined behaviour when a negative *n* was supplied. */ int fiboreccache(int n); /** * Calculates the Fibonacci-Number iteratively while using a cache to store previous values. * @param n The n'th fibonacci-number to calculate (must be positive) * @return The n'th fibonacci-number. Undefined behaviour when a negative *n* was supplied. */ int fiboitercache(int n); /** * Flushes the used cache and resets it to its initial state. * Invoking this function between two consecutive calls of any fibo*cache-function will force a * fresh calculation of all previous values, thus taking longer to calculate the results. */ void fibocache_flush(void); /** * Saves the current number of clock-cycles (system dependent!), thus remembering a point in time. */ void Timer_Start(void); /** * Calculates a timespan since the last call of Timer_Start(). * Within the ARM-Simulator, the resolution of this clock is 100 clock-cycles per second. * @return Clock-Cycles since the last Timer_Start() was called. This value is always system dependent * and needs to be normalized in order to use it for further needs. */ unsigned int Timer_Stop(void); /** * Prints the timespan between the call of Timer_Start() and Timer_Stop() in a humanly readable fashion. * Calling this function without a prior call to Timer_Stop() leads to undefined behaviour. */ void Timer_Output(void); /** * Calls Timer_Stop() and Timer_Output() in succession. */ void Timer_StopAndOutput(void); typedef int (*fiboFunction)(int); /** * Calculates and outputs the fibonacci sequence between zero and the given number of passes, * @param title The custom name of the fibo-function * @param func Pointer to the fibo-function (must conform to fiboFunction-typedef) * @param passes The maximum Fibonacci-number to calculate. Setting this number too high might lead to * unresponsive behaviour. * @return The time needed (in seconds) to calculate the fibonacci sequence upon completion. */ int RunFiboTest(const char * title, fiboFunction func, int passes); /** * Calculates and outputs the fibonacci sequence for at least a given amount of time. * @param title The custom name of the fibo-function * @param func Pointer to the fibo-function (must conform to fiboFunction-typedef) * @param secondsToRun Number of seconds to run. This value can (and will) be overstepped when a call to the specified fibo-function takes too long to respond, thus adding the time to calculate the last fibo-function call to the number of seconds to run. * @return The amount of calculated values (n'th value) in given timeframe. */ int RunFiboTestUntil(const char * title, fiboFunction func, unsigned int secondsToRun); #include #endif