Use up-to-date functions.
This commit is contained in:
parent
4e74239cca
commit
2bfb4dbce4
51
apps/speed.c
51
apps/speed.c
@ -82,7 +82,9 @@
|
|||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
||||||
#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
|
#if defined(__FreeBSD__)
|
||||||
|
# define USE_TOD
|
||||||
|
#elif !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
|
||||||
# define TIMES
|
# define TIMES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -93,6 +95,10 @@
|
|||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/times.h>
|
# include <sys/times.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_TOD
|
||||||
|
# include <sys/time.h>
|
||||||
|
# include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Depending on the VMS version, the tms structure is perhaps defined.
|
/* Depending on the VMS version, the tms structure is perhaps defined.
|
||||||
The __TMS macro will show if it was. If it wasn't defined, we should
|
The __TMS macro will show if it was. If it wasn't defined, we should
|
||||||
@ -203,6 +209,48 @@ static SIGRETTYPE sig_done(int sig)
|
|||||||
static double Time_F(int s, int usertime)
|
static double Time_F(int s, int usertime)
|
||||||
{
|
{
|
||||||
double ret;
|
double ret;
|
||||||
|
|
||||||
|
#ifdef USE_TOD
|
||||||
|
if(usertime)
|
||||||
|
{
|
||||||
|
static struct rusage tstart,tend;
|
||||||
|
|
||||||
|
if (s == START)
|
||||||
|
{
|
||||||
|
getrusage(RUSAGE_SELF,&tstart);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long i;
|
||||||
|
|
||||||
|
getrusage(RUSAGE_SELF,&tend);
|
||||||
|
i=(long)tend.ru_utime.tv_usec-(long)tstart.ru_utime.tv_usec;
|
||||||
|
ret=((double)(tend.ru_utime.tv_sec-tstart.ru_utime.tv_sec))
|
||||||
|
+((double)i)/1000000.0;
|
||||||
|
return((ret < 0.001)?0.001:ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static struct timeval tstart,tend;
|
||||||
|
long i;
|
||||||
|
|
||||||
|
if (s == START)
|
||||||
|
{
|
||||||
|
gettimeofday(&tstart,NULL);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gettimeofday(&tend,NULL);
|
||||||
|
i=(long)tend.tv_usec-(long)tstart.tv_usec;
|
||||||
|
ret=((double)(tend.tv_sec-tstart.tv_sec))+((double)i)/1000000.0;
|
||||||
|
return((ret < 0.001)?0.001:ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else /* ndef USE_TOD */
|
||||||
|
|
||||||
# ifdef TIMES
|
# ifdef TIMES
|
||||||
if (usertime)
|
if (usertime)
|
||||||
{
|
{
|
||||||
@ -239,6 +287,7 @@ static double Time_F(int s, int usertime)
|
|||||||
return((ret < 0.001)?0.001:ret);
|
return((ret < 0.001)?0.001:ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int MAIN(int, char **);
|
int MAIN(int, char **);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user