summaryrefslogtreecommitdiff
path: root/multiload/autoscaler.c
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-12-02 09:54:00 +0100
committerraveit65 <[email protected]>2020-12-13 15:45:33 +0100
commit61e25238728dd5cb9922932a5b7279eb6cdb15da (patch)
tree07c73bb9d083054c0d71d0a19e019d6f5ab5c710 /multiload/autoscaler.c
parent3cf85cb5229c3e87fed2f926004fed724e94e8cb (diff)
downloadmate-applets-61e25238728dd5cb9922932a5b7279eb6cdb15da.tar.bz2
mate-applets-61e25238728dd5cb9922932a5b7279eb6cdb15da.tar.xz
multiload: Use common subdirs - src, data
Diffstat (limited to 'multiload/autoscaler.c')
-rw-r--r--multiload/autoscaler.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/multiload/autoscaler.c b/multiload/autoscaler.c
deleted file mode 100644
index 735b2713..00000000
--- a/multiload/autoscaler.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <time.h>
-#include <glib.h>
-
-#include "autoscaler.h"
-
-/* i wish i could have used C99 initializers instead of writing this function */
-void autoscaler_init(AutoScaler *that, unsigned interval, unsigned floor)
-{
- that->update_interval = interval;
- that->floor = floor;
- that->max = 0;
- that->count = 0;
- that->last_update = 0;
- that->sum = 0.0f;
- that->last_average = 0.0f;
-}
-
-
-unsigned autoscaler_get_max(AutoScaler *that, unsigned current)
-{
- time_t now;
-
- that->sum += current;
- that->count++;
- time(&now);
-
- if((float)difftime(now, that->last_update) > that->update_interval)
- {
- float new_average = that->sum / that->count;
- float average;
-
- if(new_average < that->last_average)
- average = ((that->last_average * 0.5f) + new_average) / 1.5f;
- else
- average = new_average;
-
- that->max = average * 1.2f;
-
- that->sum = 0.0f;
- that->count = 0;
- that->last_update = now;
- that->last_average = average;
- }
-
- that->max = MAX(that->max, current);
- that->max = MAX(that->max, that->floor);
-#if 0
- printf("%p max = %u, current = %u, last_average = %f\n", that, that->max, current, that->last_average);
-#endif
- return that->max;
-}