2018-12-05 16:00:11 +01:00
|
|
|
/*
|
|
|
|
* funcs.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2018-12-05 17:58:55 +01:00
|
|
|
#include <sys/time.h>
|
2018-12-05 16:00:11 +01:00
|
|
|
|
|
|
|
#include "funcs.h"
|
|
|
|
|
2018-12-05 16:04:09 +01:00
|
|
|
extern int verbosity;
|
|
|
|
|
2018-12-05 17:58:55 +01:00
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
|
2018-12-05 16:00:11 +01:00
|
|
|
int random1000(int foo)
|
|
|
|
{
|
2018-12-05 17:58:55 +01:00
|
|
|
int value;
|
2018-12-05 16:04:09 +01:00
|
|
|
if (verbosity)
|
2018-12-05 18:14:52 +01:00
|
|
|
fprintf(stderr, ">>> %s(%d)\n", __func__, foo);
|
2018-12-05 16:00:11 +01:00
|
|
|
value = rand() % 1000;
|
|
|
|
return value;
|
|
|
|
}
|
2018-12-05 17:58:55 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
|
2018-12-06 11:14:29 +01:00
|
|
|
double get_loadavg(int foo)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
|
|
|
|
perror("read loadavg");
|
|
|
|
return -42.51;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return -42.51;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------- */
|