diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-13 09:34:20 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-13 09:46:58 -0500 |
commit | 219c969d7bf858c4df5fc6ee9b0c472a525b6b2a (patch) | |
tree | 2b3aa9585fe033c4c2a9a074e8ad90f5d0bead05 /src/test/test_channel.c | |
parent | dd6dec2665af9964d8f940c27f3f0815a649424a (diff) | |
download | tor-219c969d7bf858c4df5fc6ee9b0c472a525b6b2a.tar.gz tor-219c969d7bf858c4df5fc6ee9b0c472a525b6b2a.zip |
Use monotime_coarse for transfer times and padding times
Using absolute_msec requires a 64-bit division operation every time
we calculate it, which gets expensive on 32-bit architectures.
Instead, just use the lazy "monotime_coarse_get()" operation, and
don't convert to milliseconds until we absolutely must.
In this case, it seemed fine to use a full monotime_coarse_t rather
than a truncated "stamp" as we did to solve this problem for the
timerstamps in buf_t and packed_cell_t: There are vastly more cells
and buffer chunks than there are channels, and using 16 bytes per
channel in the worst case is not a big deal.
There are still more millisecond operations here than strictly
necessary; let's see any divisions show up in profiles.
Diffstat (limited to 'src/test/test_channel.c')
-rw-r--r-- | src/test/test_channel.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/test/test_channel.c b/src/test/test_channel.c index 55d43a04e5..425c93f42f 100644 --- a/src/test/test_channel.c +++ b/src/test/test_channel.c @@ -703,7 +703,7 @@ test_channel_inbound_cell(void *arg) old_count = test_chan_fixed_cells_recved; channel_process_cell(chan, cell); tt_int_op(test_chan_fixed_cells_recved, OP_EQ, old_count); - tt_u64_op(chan->timestamp_xfer_ms, OP_EQ, 0); + tt_assert(monotime_coarse_is_zero(&chan->timestamp_xfer)); tt_u64_op(chan->timestamp_active, OP_EQ, 0); tt_u64_op(chan->timestamp_recv, OP_EQ, 0); @@ -716,10 +716,10 @@ test_channel_inbound_cell(void *arg) channel_process_cell(chan, cell); tt_int_op(test_chan_fixed_cells_recved, OP_EQ, old_count + 1); /* We should have a series of timestamp set. */ - tt_u64_op(chan->timestamp_xfer_ms, OP_NE, 0); + tt_assert(!monotime_coarse_is_zero(&chan->timestamp_xfer)); tt_u64_op(chan->timestamp_active, OP_NE, 0); tt_u64_op(chan->timestamp_recv, OP_NE, 0); - tt_u64_op(chan->next_padding_time_ms, OP_EQ, 0); + tt_assert(monotime_is_zero(&chan->next_padding_time)); tt_u64_op(chan->n_cells_recved, OP_EQ, 1); tt_u64_op(chan->n_bytes_recved, OP_EQ, get_cell_network_size(0)); |