making a perfmeter

This commit is contained in:
2019-01-30 19:14:40 +01:00
parent b4aa5445a2
commit 67b26a733b
5 changed files with 47 additions and 20 deletions

View File

@@ -14,10 +14,10 @@ extern int verbosity;
/* --------------------------------------------------------------- */
int get_loadavg(double *where)
int get_loadavg(float *where)
{
FILE *fp;
double loads[3];
float loads[3];
int foo;
if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
@@ -25,10 +25,10 @@ if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
return -1;
}
foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2);
foo = fscanf(fp, "%f %f %f", loads, loads+1, loads+2);
if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo);
memcpy(where, loads, 3 * sizeof(double));
memcpy(where, loads, 3 * sizeof(float));
fclose(fp);

View File

@@ -1,4 +1,4 @@
int get_loadavg(double *where);
int get_loadavg(float *where);

View File

@@ -18,16 +18,16 @@ Configuration config;
/* ---------------------------------------------------------------- */
int essai_sysmetrics(int k)
{
double dvalues3[3];
float fvalues3[3];
int foo;
foo = get_loadavg(dvalues3);
foo = get_loadavg(fvalues3);
if (foo) {
fprintf(stderr, "err get load avg %d\n", foo);
return -1;
}
printf("load avg %f %f %f\n", dvalues3[0], dvalues3[1], dvalues3[2]);
printf("load avg %f %f %f\n", fvalues3[0], fvalues3[1], fvalues3[2]);
return 0;
}