litl  0.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Functions | Variables
litl_timer.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "litl_timer.h"

Go to the source code of this file.

Macros

#define ERROR_TIMER_NOT_AVAILABLE()
 
#define TIMER_DEFAULT   litl_get_time_ticks
 
#define RUN_BENCHMARK(_func_)
 
#define ticks(val)
 

Functions

void litl_time_initialize ()
 Initializes the timing mechanism. More...
 
int litl_set_timing_method (litl_timing_method_t callback)
 Selects the timing function to use. More...
 
litl_time_t litl_get_time_monotonic_raw ()
 Uses clock_gettime(CLOCK_MONOTONIC_RAW) More...
 
litl_time_t litl_get_time_monotonic ()
 Uses clock_gettime(CLOCK_MONOTONIC) More...
 
litl_time_t litl_get_time_realtime ()
 Uses clock_gettime(CLOCK_REALTIME) More...
 
litl_time_t litl_get_time_process_cputime ()
 Uses clock_gettime(CLOCK_PROCESS_CPUTIME) More...
 
litl_time_t litl_get_time_thread_cputime ()
 Uses clock_gettime(CLOCK_THREAD_CPUTIME) More...
 
litl_time_t litl_get_time_ticks ()
 Uses CPU-specific register (for instance, rdtsc for X86* processors) More...
 

Variables

litl_timing_method_t litl_get_time = TIMER_DEFAULT
 Calls the selected timing method and get the current time in ns. More...
 

Macro Definition Documentation

#define ERROR_TIMER_NOT_AVAILABLE ( )
Value:
do { \
fprintf(stderr, "Trying to use timer function %s, but it is not available on this platform\n",__FUNCTION__); \
abort(); \
} while(0)

Definition at line 15 of file litl_timer.c.

#define RUN_BENCHMARK (   _func_)
Value:
do { \
cur_score = __litl_time_benchmark_generic(_func_); \
if(cur_score > best_score) { \
best_score = cur_score; \
} \
}while(0)
int litl_set_timing_method(litl_timing_method_t callback)
Selects the timing function to use.
Definition: litl_timer.c:154
#define ticks (   val)
Value:
do { \
uint32_t __a,__d; \
asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \
(val) = ((litl_time_t)__a) | (((litl_time_t)__d)<<32); \
} while(0)
uint64_t litl_time_t
A data type for storing time stamps.
Definition: litl_types.h:112
#define TIMER_DEFAULT   litl_get_time_ticks

Definition at line 28 of file litl_timer.c.