54 lines
931 B
C
54 lines
931 B
C
/*
|
|
* funcs.c
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/time.h>
|
|
|
|
#include "funcs.h"
|
|
|
|
extern int verbosity;
|
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
int random1000(int foo)
|
|
{
|
|
int value;
|
|
if (verbosity)
|
|
fprintf(stderr, ">>> %s(%d)\n", __func__, foo);
|
|
value = rand() % 1000;
|
|
return value;
|
|
}
|
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
double dtime(void)
|
|
{
|
|
struct timeval tv;
|
|
int foo;
|
|
|
|
foo = gettimeofday(&tv, NULL);
|
|
if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__);
|
|
|
|
return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
|
|
}
|
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
double get_loadavg(int foo)
|
|
{
|
|
FILE *fp;
|
|
|
|
if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
|
|
perror("read loadavg");
|
|
return -42.51;
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
return -42.51;
|
|
}
|
|
|
|
/* --------------------------------------------------------------- */
|