[go: up one dir, main page]

Menu

[r15]: / apps / fMRI / timing.h  Maximize  Restore  History

Download this file

38 lines (29 with data), 851 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* timing.h
*
* Created by Paolo on 06/07/2007.
* Copyright 2010 Paolo Manna All rights reserved.
*
*/
#include <mach/mach.h>
#include <mach/mach_time.h>
#include <unistd.h>
static mach_timebase_info_data_t timebase = {0, 0};
inline static uint64_t nanosecs()
{
if (timebase.denom == 0)
mach_timebase_info(&timebase);
return (mach_absolute_time() * (uint64_t)(timebase.numer)) / (uint64_t)(timebase.denom);
}
inline static uint64_t usecs()
{
if (timebase.denom == 0)
mach_timebase_info(&timebase);
return (mach_absolute_time() * (uint64_t)(timebase.numer) + 500ULL) / ((uint64_t)(timebase.denom) * 1000ULL);
}
inline static uint64_t msecs()
{
if (timebase.denom == 0)
mach_timebase_info(&timebase);
return (mach_absolute_time() * (uint64_t)(timebase.numer) + 500000ULL) / ((uint64_t)(timebase.denom) * 1000000ULL);
}