Equivalent for etime in linux?

Equivalent for etime in linux?

Post by Jim Elg » Wed, 24 Jan 1996 04:00:00




>Hello, I have a problem compiling the linpack-bench for linux.
>In thje subroutine second, there is a systemcall for the function etime
>which should probabaly return the elapsed time. Linux doesn't know about
>etime. Is there an equivalent function ?
>Thanks
>--
>Christian Imiela
>Institut fuer Mechanik
>TU-Berlin

I'm not much of a C programmer, but the following C routine
can be linked with Fortran to provide the etime system call.
I strongly suspect that someone who knew what they were doing
could do it better, but it works for me using g77 on linux.
The routine "etime.c" contains:

/*  supply "etime" fortran routine

 NAME
      etime - return elapsed execution time

 SYNOPSIS
      REAL function etime (tarray)
      REAL tarray(2)

 DESCRIPTION
      This routine returns 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.

      The resolution of all timing is 1/CLK_TCK seconds, where CLK_TCK is
      processor dependent.
*/

float etime_(tarray)
float *tarray;
{
#include <unistd.h>
#include <sys/times.h>
struct tms buf;
float t1, t2, den, tot;

times(&buf);
t1 = buf.tms_utime;
t2 = buf.tms_stime;
den = sysconf(_SC_CLK_TCK);
*tarray = t1/den;
*(tarray+1) = t2/den;
tot = *tarray + *(tarray+1);
return tot;

Quote:}

 
 
 

Equivalent for etime in linux?

Post by Christian Imiel » Wed, 24 Jan 1996 04:00:00


Hello, I have a problem compiling the linpack-bench for linux.
In thje subroutine second, there is a systemcall for the function etime
which should probabaly return the elapsed time. Linux doesn't know about
etime. Is there an equivalent function ?
Thanks
--
Christian Imiela
Institut fuer Mechanik
TU-Berlin