diff options
author | rodri <rgl@antares-labs.eu> | 2021-07-21 05:05:07 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2021-07-21 05:05:07 +0000 |
commit | d276cd9961e05c184d4fd653bb9e92a288a09ec3 (patch) | |
tree | bb9de32f3e21af254f0fa447ba3f7d5759417ab5 /stats.c | |
download | musw-d276cd9961e05c184d4fd653bb9e92a288a09ec3.tar.gz musw-d276cd9961e05c184d4fd653bb9e92a288a09ec3.tar.bz2 musw-d276cd9961e05c184d4fd653bb9e92a288a09ec3.zip |
initial commit.
implemented basic server loop, with separate threads to handle connections and run the simulations.
Diffstat (limited to 'stats.c')
-rw-r--r-- | stats.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -0,0 +1,18 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> +#include "dat.h" +#include "fns.h" + +static double min(double a, double b) { return a < b? a: b; } +static double max(double a, double b) { return a > b? a: b; } + +void +statsupdate(Stats *s, double n) +{ + s->cur = n; + s->total += s->cur; + s->avg = s->total/++s->nupdates; + s->min = min(s->cur, s->min); + s->max = max(s->cur, s->max); +} |