File: etime.c

package info (click to toggle)
mopac7 1.15-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,752 kB
  • sloc: fortran: 35,321; sh: 9,039; ansic: 428; makefile: 82
file content (31 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (20)
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
/* 
NAME
     etime - return elapsed execution time

SYNOPSIS
     real function etime (tarray)
     real tarray(2)

DESCRIPTION
     These routine return elapsed runtime in seconds for the calling
     process. The argument array returns user time in the first 
     element and system time in	the second element.
     The function value is the sum of user and system time.

LAST MODIFICATION 
     January 24, 2000,  I. Cserny (cserny@atomki.hu)
*/

#include <time.h>
#include <sys/time.h>
#include <sys/resource.h>

float etime_(float *a)
{
   struct rusage t;
   getrusage(RUSAGE_SELF,&t);
   a[0] = (double)(t.ru_utime.tv_sec);
   a[0] = a[0] + (double)(t.ru_utime.tv_usec) / CLOCKS_PER_SEC;
   a[1] = (double)(t.ru_stime.tv_sec);
   a[1] = a[1] + (double)(t.ru_stime.tv_usec) / CLOCKS_PER_SEC;
}