You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
#include "genlib.h"
|
|
#include "log.h"
|
|
#include "memory.h"
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
|
|
/*gamma covariance function*/
|
|
double gammf(double h, double alpha, int cores) {
|
|
double* used_ram_t0 = malloc(sizeof(double));
|
|
getVirtualMemUsed(used_ram_t0);
|
|
|
|
clock_t t = clock();
|
|
|
|
log_info("RESULT = in progress, h = %f, alpha = %f", h, alpha);
|
|
|
|
struct cpustat initial[cores];
|
|
struct cpustat final[cores];
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
get_stats(&initial[i], i - 1);
|
|
}
|
|
|
|
float delta;
|
|
double z;
|
|
|
|
delta = pow(20., 1. / alpha) - 1.;
|
|
z = 1. / (double)(pow(1. + h * delta, alpha));
|
|
|
|
t = clock() - t;
|
|
double time_taken = ((double)t)/CLOCKS_PER_SEC; // calculate the elapsed time
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
get_stats(&final[i], i - 1);
|
|
}
|
|
|
|
for (int i = 0; i < cores; i++) {
|
|
log_info("CPU %d: %lf%%", i, calculate_load(&initial[i], &final[i]));
|
|
}
|
|
|
|
double* used_ram_tf = malloc(sizeof(double));
|
|
getVirtualMemUsed(used_ram_t0);
|
|
|
|
log_info("RESULT = success, delta = %f, z = %f, ELAPSED = %f seconds, DIF USED VIRTUAL MEM = %5.1f MB", delta, z, time_taken, *used_ram_tf - *used_ram_t0);
|
|
|
|
free(used_ram_t0);
|
|
free(used_ram_tf);
|
|
|
|
return z;
|
|
}
|