aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps-test_util.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-06-12 23:07:53 +0200
committerJulius Bünger <buenger@mytum.de>2018-06-12 23:07:53 +0200
commit8503c6fa26449228fa691c1dedfe3ca1a8d0b9ba (patch)
treef9828ab046ad048263c1040f8aa463ea7837d4ca /src/rps/rps-test_util.c
parentf24f95b6664f5e1d2a8e3cd6d03c957b0d2efd74 (diff)
downloadgnunet-8503c6fa26449228fa691c1dedfe3ca1a8d0b9ba.tar.gz
gnunet-8503c6fa26449228fa691c1dedfe3ca1a8d0b9ba.zip
rps profiler: cleaned debug output
Diffstat (limited to 'src/rps/rps-test_util.c')
-rw-r--r--src/rps/rps-test_util.c86
1 files changed, 0 insertions, 86 deletions
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 64ef5b986..9a1dfe0d8 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -37,17 +37,6 @@
37 37
38#ifdef TO_FILE 38#ifdef TO_FILE
39 39
40#define B2B_PAT "%c%c%c%c%c%c%c%c"
41#define B2B(byte) \
42 (byte & 0x80 ? '1' : '0'), \
43 (byte & 0x40 ? '1' : '0'), \
44 (byte & 0x20 ? '1' : '0'), \
45 (byte & 0x10 ? '1' : '0'), \
46 (byte & 0x08 ? '1' : '0'), \
47 (byte & 0x04 ? '1' : '0'), \
48 (byte & 0x02 ? '1' : '0'), \
49 (byte & 0x01 ? '1' : '0')
50
51#define min(x,y) ((x) > (y) ? (y) : (x)) 40#define min(x,y) ((x) > (y) ? (y) : (x))
52 41
53/** 42/**
@@ -195,14 +184,6 @@ to_file_raw_unaligned (const char *file_name,
195 bits_needed/8); 184 bits_needed/8);
196 // TODO what if no iteration happens? 185 // TODO what if no iteration happens?
197 unsigned size_buf_write = 0; 186 unsigned size_buf_write = 0;
198 LOG (GNUNET_ERROR_TYPE_DEBUG,
199 "num_bits_buf_unaligned: %u\n",
200 num_bits_buf_unaligned);
201 LOG (GNUNET_ERROR_TYPE_DEBUG,
202 "ua args: size_buf: %u, bits_needed: %u -> iter: %u\n",
203 size_buf,
204 bits_needed,
205 bytes_iter);
206 buf_write[0] = buf_unaligned; 187 buf_write[0] = buf_unaligned;
207 /* Iterate over input bytes */ 188 /* Iterate over input bytes */
208 for (unsigned i = 0; i < bytes_iter; i++) 189 for (unsigned i = 0; i < bytes_iter; i++)
@@ -243,53 +224,16 @@ to_file_raw_unaligned (const char *file_name,
243 { 224 {
244 num_bits_needed_iter = 8; 225 num_bits_needed_iter = 8;
245 } 226 }
246 LOG (GNUNET_ERROR_TYPE_DEBUG,
247 "number of bits needed in this iteration: %u\n",
248 num_bits_needed_iter);
249 mask_bits_needed_iter = ((char) 1 << num_bits_needed_iter) - 1; 227 mask_bits_needed_iter = ((char) 1 << num_bits_needed_iter) - 1;
250 LOG (GNUNET_ERROR_TYPE_DEBUG,
251 "mask needed bits (current iter): "B2B_PAT"\n",
252 B2B(mask_bits_needed_iter));
253 LOG (GNUNET_ERROR_TYPE_DEBUG,
254 "Unaligned byte: "B2B_PAT" (%u bits)\n",
255 B2B(buf_unaligned),
256 num_bits_buf_unaligned);
257 byte_input = buf[i]; 228 byte_input = buf[i];
258 LOG (GNUNET_ERROR_TYPE_DEBUG,
259 "next whole input byte: "B2B_PAT"\n",
260 B2B(byte_input));
261 byte_input &= mask_bits_needed_iter; 229 byte_input &= mask_bits_needed_iter;
262 LOG (GNUNET_ERROR_TYPE_DEBUG,
263 "input byte, needed bits: "B2B_PAT"\n",
264 B2B(byte_input));
265 num_bits_to_align = 8 - num_bits_buf_unaligned; 230 num_bits_to_align = 8 - num_bits_buf_unaligned;
266 LOG (GNUNET_ERROR_TYPE_DEBUG,
267 "number of bits needed to align unaligned bit: %u\n",
268 num_bits_to_align);
269 num_bits_to_move = min (num_bits_to_align, num_bits_needed_iter); 231 num_bits_to_move = min (num_bits_to_align, num_bits_needed_iter);
270 LOG (GNUNET_ERROR_TYPE_DEBUG,
271 "number of bits of new byte to move: %u\n",
272 num_bits_to_move);
273 mask_input_to_move = ((char) 1 << num_bits_to_move) - 1; 232 mask_input_to_move = ((char) 1 << num_bits_to_move) - 1;
274 LOG (GNUNET_ERROR_TYPE_DEBUG,
275 "mask of bits of new byte to take for moving: "B2B_PAT"\n",
276 B2B(mask_input_to_move));
277 bits_to_move = byte_input & mask_input_to_move; 233 bits_to_move = byte_input & mask_input_to_move;
278 LOG (GNUNET_ERROR_TYPE_DEBUG,
279 "masked bits of new byte to take for moving: "B2B_PAT"\n",
280 B2B(bits_to_move));
281 distance_shift_bits = num_bits_buf_unaligned; 234 distance_shift_bits = num_bits_buf_unaligned;
282 LOG (GNUNET_ERROR_TYPE_DEBUG,
283 "distance needed to shift bits to their correct spot: %u\n",
284 distance_shift_bits);
285 bits_moving = bits_to_move << distance_shift_bits; 235 bits_moving = bits_to_move << distance_shift_bits;
286 LOG (GNUNET_ERROR_TYPE_DEBUG,
287 "shifted, masked bits of new byte being moved: "B2B_PAT"\n",
288 B2B(bits_moving));
289 byte_to_fill = buf_unaligned | bits_moving; 236 byte_to_fill = buf_unaligned | bits_moving;
290 LOG (GNUNET_ERROR_TYPE_DEBUG,
291 "byte being filled: "B2B_PAT"\n",
292 B2B(byte_to_fill));
293 if (num_bits_buf_unaligned + num_bits_needed_iter > 8) 237 if (num_bits_buf_unaligned + num_bits_needed_iter > 8)
294 { 238 {
295 /* buf_unaligned was aligned by filling 239 /* buf_unaligned was aligned by filling
@@ -299,22 +243,10 @@ to_file_raw_unaligned (const char *file_name,
299 243
300 /* store the leftover, unaligned bits in buffer */ 244 /* store the leftover, unaligned bits in buffer */
301 mask_input_leftover = mask_bits_needed_iter & (~ mask_input_to_move); 245 mask_input_leftover = mask_bits_needed_iter & (~ mask_input_to_move);
302 LOG (GNUNET_ERROR_TYPE_DEBUG,
303 "mask of leftover bits of new byte: "B2B_PAT"\n",
304 B2B(mask_input_leftover));
305 byte_input_leftover = byte_input & mask_input_leftover; 246 byte_input_leftover = byte_input & mask_input_leftover;
306 LOG (GNUNET_ERROR_TYPE_DEBUG,
307 "masked, leftover bits of new byte: "B2B_PAT"\n",
308 B2B(byte_input_leftover));
309 num_bits_leftover = num_bits_needed_iter - num_bits_to_move; 247 num_bits_leftover = num_bits_needed_iter - num_bits_to_move;
310 LOG (GNUNET_ERROR_TYPE_DEBUG,
311 "number of unaligned bits left: %u\n",
312 num_bits_leftover);
313 num_bits_discard = 8 - num_bits_needed_iter; 248 num_bits_discard = 8 - num_bits_needed_iter;
314 byte_unaligned_new = byte_input_leftover >> num_bits_to_move; 249 byte_unaligned_new = byte_input_leftover >> num_bits_to_move;
315 LOG (GNUNET_ERROR_TYPE_DEBUG,
316 "new unaligned byte: "B2B_PAT"\n",
317 B2B(byte_unaligned_new));
318 buf_unaligned = byte_unaligned_new; 250 buf_unaligned = byte_unaligned_new;
319 num_bits_buf_unaligned = num_bits_leftover % 8; 251 num_bits_buf_unaligned = num_bits_leftover % 8;
320 } 252 }
@@ -324,24 +256,6 @@ to_file_raw_unaligned (const char *file_name,
324 buf_unaligned = byte_to_fill; 256 buf_unaligned = byte_to_fill;
325 num_bits_buf_unaligned = (num_bits_buf_unaligned + bits_needed) % 8; 257 num_bits_buf_unaligned = (num_bits_buf_unaligned + bits_needed) % 8;
326 } 258 }
327 ///* Byte to be completed will consist of what is left in the unaligned
328 // * byte and the rest of the input byte */
329 //LOG (GNUNET_ERROR_TYPE_DEBUG,
330 // "ua: %u - %x, %x << %u = %x\n",
331 // i,
332 // buf_unaligned,
333 // num_bits_buf_unaligned,
334 // (char) ((char) buf_unaligned << num_bits_buf_unaligned));
335 //buf_write[i] = buf_write[i] |
336 // (char) ((char) buf_unaligned << num_bits_buf_unaligned);
337 //LOG (GNUNET_ERROR_TYPE_DEBUG,
338 // "ua: %x\n",
339 // buf_write[i]);
340 //buf_unaligned = buf[i] >> num_bits_buf_unaligned;
341 //LOG (GNUNET_ERROR_TYPE_DEBUG,
342 // "ua: %x\n"
343 // "---\n",
344 // buf_unaligned);
345 } 259 }
346 to_file_raw (file_name, buf_write, size_buf_write); 260 to_file_raw (file_name, buf_write, size_buf_write);
347 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n"); 261 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");