X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fload.c;h=d374d7a17ca6c52aed41d6ec098f4c25ac02d857;hb=f249a80a2b1e52b24969782e8afb30b86c373ae2;hp=c7ef07295e14c1570b5bd44de604a8e3a53fb46a;hpb=502af2167f7c218366666ca4944bd7cc54b5b19a;p=oweals%2Fgnunet.git diff --git a/src/util/load.c b/src/util/load.c index c7ef07295..d374d7a17 100644 --- a/src/util/load.c +++ b/src/util/load.c @@ -1,10 +1,10 @@ /* This file is part of GNUnet. - (C) 2010 Christian Grothoff (and other contributing authors) + Copyright (C) 2010, 2013 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your + by the Free Software Foundation; either version 3, or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** @@ -24,9 +24,10 @@ * @author Christian Grothoff */ #include "platform.h" -#include "gnunet_load_lib.h" +#include "gnunet_util_lib.h" -#define DEBUG_LOAD GNUNET_NO + +#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) /** * Values we track for load calculations. @@ -86,18 +87,18 @@ internal_update (struct GNUNET_LOAD_Value *load) struct GNUNET_TIME_Relative delta; unsigned int n; - if (load->autodecline.rel_value == GNUNET_TIME_UNIT_FOREVER_REL.rel_value) + if (load->autodecline.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) return; delta = GNUNET_TIME_absolute_get_duration (load->last_update); - if (delta.rel_value < load->autodecline.rel_value) + if (delta.rel_value_us < load->autodecline.rel_value_us) return; - if (load->autodecline.rel_value == 0) + if (0 == load->autodecline.rel_value_us) { load->runavg_delay = 0.0; load->load = 0; return; } - n = delta.rel_value / load->autodecline.rel_value; + n = delta.rel_value_us / load->autodecline.rel_value_us; if (n > 16) { load->runavg_delay = 0.0; @@ -125,7 +126,7 @@ GNUNET_LOAD_value_init (struct GNUNET_TIME_Relative autodecline) { struct GNUNET_LOAD_Value *ret; - ret = GNUNET_malloc (sizeof (struct GNUNET_LOAD_Value)); + ret = GNUNET_new (struct GNUNET_LOAD_Value); ret->autodecline = autodecline; ret->last_update = GNUNET_TIME_absolute_get (); return ret; @@ -164,7 +165,7 @@ calculate_load (struct GNUNET_LOAD_Value *load) if (load->cummulative_request_count <= 1) return; /* calcuate std dev of latency; we have for n values of "i" that: - * + * * avg = (sum val_i) / n * stddev = (sum (val_i - avg)^2) / (n-1) * = (sum (val_i^2 - 2 avg val_i + avg^2) / (n-1)