Commit 31866040 authored by Jorge Machado's avatar Jorge Machado

Compute peak to peak statistics

parent 572a47a7
......@@ -24,6 +24,7 @@ struct ts_stats {
double std;
double min;
double max;
double peak_to_peak;
unsigned int ts_per_second;
unsigned int ts_total;
};
......@@ -62,6 +63,8 @@ static double compute_min(const double *values,
const unsigned int n_values);
static double compute_max(const double *values,
const unsigned int n_values);
static double compute_peak_to_peak(const double min,
const double max);
static double compute_mean(const double *values,
const unsigned int n_values);
static double compute_stdev(const double *values,
......
......@@ -96,6 +96,7 @@ int run_stats_engine(stats_engine engine, int verbose)
engine->stats.max = compute_max(engine->diff_ts, engine->n_ts);
engine->stats.mean = compute_mean(engine->diff_ts, engine->n_ts);
engine->stats.std = compute_stdev(engine->diff_ts, engine->n_ts, engine->stats.mean);
engine->stats.peak_to_peak = compute_peak_to_peak(engine->stats.min, engine->stats.max);
count_ts = compute_ts_per_second(engine->usr_ts[engine->current_ts].t.tv_sec,
engine->usr_ts, engine->n_ts);
if(count_ts != -1)
......@@ -160,10 +161,11 @@ static void log_stats_engine(stats_engine engine, int verbose)
LOG(engine, "Iterations: %d", engine->n_iter);
LOG(engine, "Metrics => Total timestamps: %d, Timestamps per second: %d\n"
"max: %f %s, min %f %s\n"
"max: %f %s, min %f %s, peak to peak %f %s\n"
"mean: %f %s, stdev: %f %s",
engine->stats.ts_total, engine->stats.ts_per_second,
engine->stats.max, METRICS_UNIT, engine->stats.min, METRICS_UNIT,
engine->stats.max, METRICS_UNIT, engine->stats.min, METRICS_UNIT,
engine->stats.peak_to_peak, METRICS_UNIT,
engine->stats.mean, METRICS_UNIT, engine->stats.std, METRICS_UNIT);
LOG(engine, "\n============================================================\n");
log_clear(engine);
......@@ -265,6 +267,11 @@ static double compute_min(const double *values,
return min;
}
static double compute_peak_to_peak(const double min, const double max)
{
return max-min;
}
static double compute_max(const double *values,
const unsigned int n_values)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment