forked from dfeldmann/nsCouette
-
Notifications
You must be signed in to change notification settings - Fork 1
/
time.c
43 lines (40 loc) · 2.12 KB
/
time.c
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
38
39
40
41
42
43
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! This file is part of nsCouette -- A high-performance code for direct !
! numerical simulations of turbulent Taylor-Couette flow !
! !
! Copyright (C) 2019 Marc Avila, Bjoern Hof, Jose Manuel Lopez, Markus Rampp, !
! Liang Shi, Alberto Vela-Martin, Daniel Feldmann. !
! !
! nsCouette is free software: you can redistribute it and/or modify it under !
! the terms of the GNU General Public License as published by the Free !
! Software Foundation, either version 3 of the License, or (at your option) !
! any later version. !
! !
! nsCouette is distributed in the hope that it will be useful, but WITHOUT ANY !
! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS !
! FOR A PARTICULAR PURPOSE. See the GNU General Public License for more !
! details. !
! !
! You should have received a copy of the GNU General Public License along with !
! nsCouette. If not, see <http://www.gnu.org/licenses/>. !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
#include <sys/time.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include "config-f90.h"
#endif
/* Return number of microseconds since 1.1.1970, in a 64 bit integer.
* (with 2^64 us ~ 6 * 10^5 years, this should be sufficiently overflow safe)
*/
int64_t ftimings_microseconds_since_epoch(void) {
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0) {
perror("gettimeofday");
exit(1);
}
return (int64_t) (tv.tv_sec) * ((int64_t) 1000000) + (int64_t)(tv.tv_usec);
}