Select Git revision
-
root authored
git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3 4ea69e1a-61f1-4043-bf83-b5c94c648137
root authoredgit-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3 4ea69e1a-61f1-4043-bf83-b5c94c648137
profiler.h NaN GiB
/*
* =====================================================================================
*
* Description: auxiliary functions for profiling
*
* Version: 1.0
* Created: 29.01.2021 08:40:18
* Revision: none
* Compiler: hipc or nvcc
*
* Author: Henning Fehrmann (), henning.fehrmann@aei.mpg.de
* Organization: AEI Hannover
* License: GNU General Public License v2
*
* =====================================================================================
*/
#include <time.h>
#include <stdio.h>
struct runtime
{
struct timespec start;
struct timespec stop;
char tag[128];
};
void
timer_start
(
struct runtime * timer,
char tag[128]
)
{
struct timespec start;
sprintf(timer->tag,"%s", tag);
clock_gettime(CLOCK_REALTIME , &start);
timer->start = start;
// printf("--------> start timer: %s\n", timer->tag);
}
static unsigned long x=123456789, y=362436069, z=521288629;
unsigned long
xorshf96
(
void
)
{
// NOT thread save
unsigned long t;
x ^= x << 16;
x ^= x >> 5;
x ^= x << 1;
t = x;
x = y;
y = z;
z = t ^ x ^ y;
return z;
}
double
timer_stop
(
struct runtime * timer
)
{
struct timespec stop;
clock_gettime(CLOCK_REALTIME , &stop);
timer->stop = stop;
double res= (double)
(
(timer->stop).tv_sec - (timer->start).tv_sec
)*1000.
+
(double)
(
(timer->stop).tv_nsec - (timer->start).tv_nsec
)/1000000.
;
printf("%g [ms]\t%s\n", res, timer->tag);
return res;
}