mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-29 06:51:10 +00:00
9690567d50
Show the average and standard deviation of the latency in addition to the frame rate. Add options to print the output in machine-readable form, and to control the frequency and total number of statistics that will be output. https://bugzilla.gnome.org/show_bug.cgi?id=685460
44 lines
843 B
C
44 lines
843 B
C
/* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
|
|
|
|
#include <math.h>
|
|
#include "variable.h"
|
|
|
|
void
|
|
variable_add_weighted (Variable *variable,
|
|
double value,
|
|
double weight)
|
|
{
|
|
variable->weight += weight;
|
|
variable->sum += weight * value;
|
|
variable->sum2 += weight * value * value;
|
|
}
|
|
|
|
void
|
|
variable_add (Variable *variable,
|
|
double value)
|
|
{
|
|
variable_add_weighted (variable, value, 1.);
|
|
}
|
|
|
|
double
|
|
variable_mean (Variable *variable)
|
|
{
|
|
return variable->sum / variable->weight;
|
|
}
|
|
|
|
double
|
|
variable_standard_deviation (Variable *variable)
|
|
{
|
|
double mean = variable_mean (variable);
|
|
return sqrt (variable->sum2 / variable->weight - mean * mean);
|
|
}
|
|
|
|
void
|
|
variable_reset (Variable *variable)
|
|
{
|
|
variable->weight = 0;
|
|
variable->sum = 0;
|
|
variable->sum2 = 0;
|
|
}
|
|
|