MySQL 9.1.0
Source Code Documentation
|
Multi-platform timer code. More...
#include <stdint.h>
#include <stdio.h>
#include "my_config.h"
#include "my_inttypes.h"
#include "my_rdtsc.h"
#include <sys/time.h>
#include <sys/times.h>
Macros | |
#define | MY_TIMER_ITERATIONS 1000000 |
Functions | |
ulonglong | my_timer_cycles (void) |
A cycle timer. More... | |
ulonglong | my_timer_nanoseconds (void) |
A namoseconds timer. More... | |
ulonglong | my_timer_microseconds (void) |
A microseconds timer. More... | |
ulonglong | my_timer_milliseconds (void) |
A millisecond timer. More... | |
ulonglong | my_timer_ticks (void) |
A ticks timer. More... | |
ulonglong | my_timer_thread_cpu (void) |
THREAD_CPU timer. More... | |
static void | my_timer_init_overhead (ulonglong *overhead, ulonglong(*cycle_timer)(void), ulonglong(*this_timer)(void), ulonglong best_timer_overhead) |
static ulonglong | my_timer_init_resolution (ulonglong(*this_timer)(void), ulonglong overhead_times_2) |
static ulonglong | my_timer_init_frequency (MY_TIMER_INFO *mti) |
void | my_timer_init (MY_TIMER_INFO *mti) |
Timer initialization function. More... | |
Multi-platform timer code.
Functions:
my_timer_cycles ulonglong cycles my_timer_nanoseconds ulonglong nanoseconds my_timer_microseconds ulonglong "microseconds" my_timer_milliseconds ulonglong milliseconds my_timer_ticks ulonglong ticks my_timer_thread_cpu ulonglong thread_cpu my_timer_init initialization / test
We'll call the first 6 functions (the ones that return a ulonglong) "my_timer_xxx" functions. Each my_timer_xxx function returns a 64-bit timing value since an arbitrary 'epoch' start. Since the only purpose is to determine elapsed times, wall-clock time-of-day is not known and not relevant.
The my_timer_init function is necessary for initializing. It returns information (underlying routine name, frequency, resolution, overhead) about all my_timer_xxx functions. A program should call my_timer_init once, use the information to decide what my_timer_xxx function to use, and subsequently call that function by function pointer.
A typical use would be: my_timer_init() ... once, at program start ... time1= my_timer_xxx() ... time before start [code that's timed] time2= my_timer_xxx() ... time after end elapsed_time= (time2 - time1) - overhead
#define MY_TIMER_ITERATIONS 1000000 |
ulonglong my_timer_cycles | ( | void | ) |
A cycle timer.
void my_timer_init | ( | MY_TIMER_INFO * | mti | ) |
Timer initialization function.
[out] | mti | the timer characteristics. |
|
static |
|
static |
|
static |
ulonglong my_timer_microseconds | ( | void | ) |
A microseconds timer.
ulonglong my_timer_milliseconds | ( | void | ) |
A millisecond timer.
ulonglong my_timer_nanoseconds | ( | void | ) |
A namoseconds timer.
ulonglong my_timer_thread_cpu | ( | void | ) |
THREAD_CPU timer.
A THREAD CPU timer.
Expressed in nanoseconds.
ulonglong my_timer_ticks | ( | void | ) |
A ticks timer.