aboutsummaryrefslogtreecommitdiff
path: root/src/util/load.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
commit83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch)
treed0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/util/load.c
parent28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff)
downloadgnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz
gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip
curly wars / auto-indentation
Diffstat (limited to 'src/util/load.c')
-rw-r--r--src/util/load.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/util/load.c b/src/util/load.c
index 1df1abc7c..e978a950d 100644
--- a/src/util/load.c
+++ b/src/util/load.c
@@ -94,23 +94,23 @@ internal_update (struct GNUNET_LOAD_Value *load)
94 if (delta.rel_value < load->autodecline.rel_value) 94 if (delta.rel_value < load->autodecline.rel_value)
95 return; 95 return;
96 if (load->autodecline.rel_value == 0) 96 if (load->autodecline.rel_value == 0)
97 { 97 {
98 load->runavg_delay = 0.0; 98 load->runavg_delay = 0.0;
99 load->load = 0; 99 load->load = 0;
100 return; 100 return;
101 } 101 }
102 n = delta.rel_value / load->autodecline.rel_value; 102 n = delta.rel_value / load->autodecline.rel_value;
103 if (n > 16) 103 if (n > 16)
104 { 104 {
105 load->runavg_delay = 0.0; 105 load->runavg_delay = 0.0;
106 load->load = 0; 106 load->load = 0;
107 return; 107 return;
108 } 108 }
109 while (n > 0) 109 while (n > 0)
110 { 110 {
111 n--; 111 n--;
112 load->runavg_delay = (load->runavg_delay * 7.0) / 8.0; 112 load->runavg_delay = (load->runavg_delay * 7.0) / 8.0;
113 } 113 }
114} 114}
115 115
116 116
@@ -142,7 +142,7 @@ GNUNET_LOAD_value_init (struct GNUNET_TIME_Relative autodecline)
142 */ 142 */
143void 143void
144GNUNET_LOAD_value_set_decline (struct GNUNET_LOAD_Value *load, 144GNUNET_LOAD_value_set_decline (struct GNUNET_LOAD_Value *load,
145 struct GNUNET_TIME_Relative autodecline) 145 struct GNUNET_TIME_Relative autodecline)
146{ 146{
147 internal_update (load); 147 internal_update (load);
148 load->autodecline = autodecline; 148 load->autodecline = autodecline;
@@ -177,10 +177,10 @@ calculate_load (struct GNUNET_LOAD_Value *load)
177 nm1 = n - 1.0; 177 nm1 = n - 1.0;
178 avgdel = sum_val_i / n; 178 avgdel = sum_val_i / n;
179 stddev = 179 stddev =
180 (((double) load->cummulative_squared_delay) - 2.0 * avgdel * sum_val_i + 180 (((double) load->cummulative_squared_delay) - 2.0 * avgdel * sum_val_i +
181 n * avgdel * avgdel) / nm1; 181 n * avgdel * avgdel) / nm1;
182 if (stddev <= 0) 182 if (stddev <= 0)
183 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 */
184 /* now calculate load based on how far out we are from 184 /* now calculate load based on how far out we are from
185 * 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 */
186 if (load->runavg_delay < avgdel) 186 if (load->runavg_delay < avgdel)
@@ -243,11 +243,11 @@ GNUNET_LOAD_update (struct GNUNET_LOAD_Value *load, uint64_t data)
243 internal_update (load); 243 internal_update (load);
244 load->last_update = GNUNET_TIME_absolute_get (); 244 load->last_update = GNUNET_TIME_absolute_get ();
245 if (data > 64 * 1024) 245 if (data > 64 * 1024)
246 { 246 {
247 /* very large */ 247 /* very large */
248 load->load = 100.0; 248 load->load = 100.0;
249 return; 249 return;
250 } 250 }
251 dv = (uint32_t) data; 251 dv = (uint32_t) data;
252 load->cummulative_delay += dv; 252 load->cummulative_delay += dv;
253 load->cummulative_squared_delay += dv * dv; 253 load->cummulative_squared_delay += dv * dv;