forked from lanl/MultiMatTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.c
39 lines (33 loc) · 1.14 KB
/
timer.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
/*
* Copyright (c) 2017, Los Alamos National Security, LLC.
* All rights Reserved.
*
* This is the code released under LANL Copyright Disclosure C17041/LA-CC-17-041
* Copyright 2017. Los Alamos National Security, LLC. This material was produced
* under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
* Laboratory (LANL), which is operated by Los Alamos National Security, LLC
* for the U.S. Department of Energy. See LICENSE file for details.
*
* Released under the New BSD License
*
* Bob Robey [email protected] and Rao Garimella [email protected]
*/
#include <sys/time.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include "timer.h"
void cpu_timer_start(struct timeval *tstart_cpu){
gettimeofday(tstart_cpu, NULL);
}
double cpu_timer_stop(struct timeval tstart_cpu){
double result;
struct timeval tstop_cpu, tresult;
gettimeofday(&tstop_cpu, NULL);
tresult.tv_sec = tstop_cpu.tv_sec - tstart_cpu.tv_sec;
tresult.tv_usec = tstop_cpu.tv_usec - tstart_cpu.tv_usec;
result = (double)tresult.tv_sec + (double)tresult.tv_usec*1.0e-6;
return(result);
}