[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: rps profiler: correct condi
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: rps profiler: correct condition for writing bytes |
Date: |
Tue, 03 Jul 2018 11:38:46 +0200 |
This is an automated email from the git hooks/post-receive script.
julius-buenger pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 04bc4d622 rps profiler: correct condition for writing bytes
04bc4d622 is described below
commit 04bc4d622a4ebdc903fa6feb35192a4efddcc2ca
Author: Julius Bünger <address@hidden>
AuthorDate: Tue Jul 3 10:30:30 2018 +0200
rps profiler: correct condition for writing bytes
---
src/rps/rps-test_util.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 78 insertions(+), 2 deletions(-)
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index d47e4952f..08fe96097 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -31,6 +31,17 @@
#define LOG(kind, ...) GNUNET_log_from(kind,"rps-test_util",__VA_ARGS__)
+#define B2B_PAT "%c%c%c%c%c%c%c%c"
+#define B2B(byte) \
+ (byte & 0x80 ? '1' : '0'), \
+ (byte & 0x40 ? '1' : '0'), \
+ (byte & 0x20 ? '1' : '0'), \
+ (byte & 0x10 ? '1' : '0'), \
+ (byte & 0x08 ? '1' : '0'), \
+ (byte & 0x04 ? '1' : '0'), \
+ (byte & 0x02 ? '1' : '0'), \
+ (byte & 0x01 ? '1' : '0')
+
#ifndef TO_FILE
#define TO_FILE
#endif /* TO_FILE */
@@ -155,6 +166,9 @@ to_file_raw (const char *file_name, const char *buf, size_t
size_buf)
return;
}
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Wrote %u bytes raw.\n",
+ size_written);
if (GNUNET_YES != GNUNET_DISK_file_close (f))
LOG (GNUNET_ERROR_TYPE_WARNING,
"Unable to close file\n");
@@ -180,6 +194,8 @@ to_file_raw_unaligned (const char *file_name,
// num_bits_buf_unaligned = bits_needed % 8;
// return;
//}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Was asked to write %u bits\n", bits_needed);
char buf_write[size_buf + 1];
const unsigned bytes_iter = (0 != bits_needed % 8?
@@ -187,6 +203,14 @@ to_file_raw_unaligned (const char *file_name,
bits_needed/8);
// TODO what if no iteration happens?
unsigned size_buf_write = 0;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "num_bits_buf_unaligned: %u\n",
+ num_bits_buf_unaligned);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "ua args: size_buf: %u, bits_needed: %u -> iter: %u\n",
+ size_buf,
+ bits_needed,
+ bytes_iter);
buf_write[0] = buf_unaligned;
/* Iterate over input bytes */
for (unsigned i = 0; i < bytes_iter; i++)
@@ -227,17 +251,57 @@ to_file_raw_unaligned (const char *file_name,
{
num_bits_needed_iter = 8;
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "number of bits needed in this iteration: %u\n",
+ num_bits_needed_iter);
mask_bits_needed_iter = ((char) 1 << num_bits_needed_iter) - 1;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "mask needed bits (current iter): "B2B_PAT"\n",
+ B2B(mask_bits_needed_iter));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Unaligned byte: "B2B_PAT" (%u bits)\n",
+ B2B(buf_unaligned),
+ num_bits_buf_unaligned);
byte_input = buf[i];
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "next whole input byte: "B2B_PAT"\n",
+ B2B(byte_input));
byte_input &= mask_bits_needed_iter;
num_bits_to_align = 8 - num_bits_buf_unaligned;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "input byte, needed bits: "B2B_PAT"\n",
+ B2B(byte_input));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "number of bits needed to align unaligned bit: %u\n",
+ num_bits_to_align);
num_bits_to_move = min (num_bits_to_align, num_bits_needed_iter);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "number of bits of new byte to move: %u\n",
+ num_bits_to_move);
mask_input_to_move = ((char) 1 << num_bits_to_move) - 1;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "mask of bits of new byte to take for moving: "B2B_PAT"\n",
+ B2B(mask_input_to_move));
bits_to_move = byte_input & mask_input_to_move;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "masked bits of new byte to take for moving: "B2B_PAT"\n",
+ B2B(bits_to_move));
distance_shift_bits = num_bits_buf_unaligned;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "distance needed to shift bits to their correct spot: %u\n",
+ distance_shift_bits);
bits_moving = bits_to_move << distance_shift_bits;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "shifted, masked bits of new byte being moved: "B2B_PAT"\n",
+ B2B(bits_moving));
byte_to_fill = buf_unaligned | bits_moving;
- if (num_bits_buf_unaligned + num_bits_needed_iter > 8)
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "byte being filled: "B2B_PAT"\n",
+ B2B(byte_to_fill));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "pending bytes: %u\n",
+ num_bits_buf_unaligned + num_bits_needed_iter);
+ if (num_bits_buf_unaligned + num_bits_needed_iter >= 8)
{
/* buf_unaligned was aligned by filling
* -> can be written to storage */
@@ -246,10 +310,22 @@ to_file_raw_unaligned (const char *file_name,
/* store the leftover, unaligned bits in buffer */
mask_input_leftover = mask_bits_needed_iter & (~ mask_input_to_move);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "mask of leftover bits of new byte: "B2B_PAT"\n",
+ B2B(mask_input_leftover));
byte_input_leftover = byte_input & mask_input_leftover;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "masked, leftover bits of new byte: "B2B_PAT"\n",
+ B2B(byte_input_leftover));
num_bits_leftover = num_bits_needed_iter - num_bits_to_move;
- num_bits_discard = 8 - num_bits_needed_iter;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "number of unaligned bits left: %u\n",
+ num_bits_leftover);
+ //num_bits_discard = 8 - num_bits_needed_iter;
byte_unaligned_new = byte_input_leftover >> num_bits_to_move;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "new unaligned byte: "B2B_PAT"\n",
+ B2B(byte_unaligned_new));
buf_unaligned = byte_unaligned_new;
num_bits_buf_unaligned = num_bits_leftover % 8;
}
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: rps profiler: correct condition for writing bytes,
gnunet <=