File: lu_timing.c

package info (click to toggle)
armci-mpi 0.3.1~beta-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,868 kB
  • sloc: ansic: 13,028; sh: 243; makefile: 94; fortran: 44
file content (44 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download | duplicates (5)
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
44
/** @file
 * Copyright (c) 1995 by PDCL Corporation.  All Rights Reserved.
 *
 * NAME
 *   timing.c
 * PURPOSE
 *   Timing routines for calculating the execution time:
 *     void start_timer(void);  Set the timer.
 *     double elapsed_time(void);  Return the timing elapsed since
 *                                 the timer has been set.
 * NOTES
 *   Jialin Ju - Oct 16, 1995 Created.
 */

#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/errno.h>
#include <sys/time.h>

/** Timing routines that use standard Unix gettingofday() */
static struct timeval start_time, finish_time;

/** Start measuring a time delay */
void start_timer(void)
{
    gettimeofday( &start_time, NULL);
}

/** Retunrn elapsed time in milliseconds */
double elapsed_time(void)
{
    gettimeofday( &finish_time, NULL);
    return(1000.0*(finish_time.tv_sec - start_time.tv_sec) +
           (finish_time.tv_usec - start_time.tv_usec)/1000.0 );
}

/** Return the stopping time in milliseconds */
double stop_time(void)
{
    gettimeofday( &finish_time, NULL);
    return(1000.0*finish_time.tv_sec + finish_time.tv_usec/1000.0);
}