diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-11 09:43:04 +0000 |
commit | d9d94d0e53d26af75ec8241383d166544ebd79f3 (patch) | |
tree | 9080b73624389403a198257fe0547bb4634e64d2 /src/util/load.c | |
parent | 2d792ee2e9cc0c993b8907e2c8edb0c2b8465343 (diff) | |
download | gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.tar.gz gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.zip |
converting to GNUNET_LOG_from*
Diffstat (limited to 'src/util/load.c')
-rw-r--r-- | src/util/load.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/util/load.c b/src/util/load.c index 39e861597..1df1abc7c 100644 --- a/src/util/load.c +++ b/src/util/load.c | |||
@@ -28,6 +28,8 @@ | |||
28 | 28 | ||
29 | #define DEBUG_LOAD GNUNET_EXTRA_LOGGING | 29 | #define DEBUG_LOAD GNUNET_EXTRA_LOGGING |
30 | 30 | ||
31 | #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) | ||
32 | |||
31 | /** | 33 | /** |
32 | * Values we track for load calculations. | 34 | * Values we track for load calculations. |
33 | */ | 35 | */ |
@@ -92,23 +94,23 @@ internal_update (struct GNUNET_LOAD_Value *load) | |||
92 | if (delta.rel_value < load->autodecline.rel_value) | 94 | if (delta.rel_value < load->autodecline.rel_value) |
93 | return; | 95 | return; |
94 | if (load->autodecline.rel_value == 0) | 96 | if (load->autodecline.rel_value == 0) |
95 | { | 97 | { |
96 | load->runavg_delay = 0.0; | 98 | load->runavg_delay = 0.0; |
97 | load->load = 0; | 99 | load->load = 0; |
98 | return; | 100 | return; |
99 | } | 101 | } |
100 | n = delta.rel_value / load->autodecline.rel_value; | 102 | n = delta.rel_value / load->autodecline.rel_value; |
101 | if (n > 16) | 103 | if (n > 16) |
102 | { | 104 | { |
103 | load->runavg_delay = 0.0; | 105 | load->runavg_delay = 0.0; |
104 | load->load = 0; | 106 | load->load = 0; |
105 | return; | 107 | return; |
106 | } | 108 | } |
107 | while (n > 0) | 109 | while (n > 0) |
108 | { | 110 | { |
109 | n--; | 111 | n--; |
110 | load->runavg_delay = (load->runavg_delay * 7.0) / 8.0; | 112 | load->runavg_delay = (load->runavg_delay * 7.0) / 8.0; |
111 | } | 113 | } |
112 | } | 114 | } |
113 | 115 | ||
114 | 116 | ||
@@ -140,7 +142,7 @@ GNUNET_LOAD_value_init (struct GNUNET_TIME_Relative autodecline) | |||
140 | */ | 142 | */ |
141 | void | 143 | void |
142 | GNUNET_LOAD_value_set_decline (struct GNUNET_LOAD_Value *load, | 144 | GNUNET_LOAD_value_set_decline (struct GNUNET_LOAD_Value *load, |
143 | struct GNUNET_TIME_Relative autodecline) | 145 | struct GNUNET_TIME_Relative autodecline) |
144 | { | 146 | { |
145 | internal_update (load); | 147 | internal_update (load); |
146 | load->autodecline = autodecline; | 148 | load->autodecline = autodecline; |
@@ -175,10 +177,10 @@ calculate_load (struct GNUNET_LOAD_Value *load) | |||
175 | nm1 = n - 1.0; | 177 | nm1 = n - 1.0; |
176 | avgdel = sum_val_i / n; | 178 | avgdel = sum_val_i / n; |
177 | stddev = | 179 | stddev = |
178 | (((double) load->cummulative_squared_delay) - 2.0 * avgdel * sum_val_i + | 180 | (((double) load->cummulative_squared_delay) - 2.0 * avgdel * sum_val_i + |
179 | n * avgdel * avgdel) / nm1; | 181 | n * avgdel * avgdel) / nm1; |
180 | if (stddev <= 0) | 182 | if (stddev <= 0) |
181 | stddev = 0.01; /* must have been rounding error or zero; prevent division by zero */ | 183 | stddev = 0.01; /* must have been rounding error or zero; prevent division by zero */ |
182 | /* now calculate load based on how far out we are from | 184 | /* now calculate load based on how far out we are from |
183 | * std dev; or if we are below average, simply assume load zero */ | 185 | * std dev; or if we are below average, simply assume load zero */ |
184 | if (load->runavg_delay < avgdel) | 186 | if (load->runavg_delay < avgdel) |
@@ -241,11 +243,11 @@ GNUNET_LOAD_update (struct GNUNET_LOAD_Value *load, uint64_t data) | |||
241 | internal_update (load); | 243 | internal_update (load); |
242 | load->last_update = GNUNET_TIME_absolute_get (); | 244 | load->last_update = GNUNET_TIME_absolute_get (); |
243 | if (data > 64 * 1024) | 245 | if (data > 64 * 1024) |
244 | { | 246 | { |
245 | /* very large */ | 247 | /* very large */ |
246 | load->load = 100.0; | 248 | load->load = 100.0; |
247 | return; | 249 | return; |
248 | } | 250 | } |
249 | dv = (uint32_t) data; | 251 | dv = (uint32_t) data; |
250 | load->cummulative_delay += dv; | 252 | load->cummulative_delay += dv; |
251 | load->cummulative_squared_delay += dv * dv; | 253 | load->cummulative_squared_delay += dv * dv; |