diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-11-21 12:28:16 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-11-27 09:43:15 -0500 |
commit | c3c0a05f51eff73e624b18f651339ed08a122e3d (patch) | |
tree | f679e50de45db6c6a5218bdb0815da4f5f058172 /src/test/test_oom.c | |
parent | da82e0b5795c449f4442c87e065e9a60da4892a8 (diff) | |
download | tor-c3c0a05f51eff73e624b18f651339ed08a122e3d.tar.gz tor-c3c0a05f51eff73e624b18f651339ed08a122e3d.zip |
Add a new notion of "stamps" to be a fast 32-bit monotonic timestamp
The goal here is to replace our use of msec-based timestamps with
something less precise, but easier to calculate. We're doing this
because calculating lots of msec-based timestamps requires lots of
64/32 division operations, which can be inefficient on 32-bit
platforms.
We make sure that these stamps can be calculated using only the
coarse monotonic timer and 32-bit bitwise operations.
Diffstat (limited to 'src/test/test_oom.c')
-rw-r--r-- | src/test/test_oom.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/test/test_oom.c b/src/test/test_oom.c index cf28690a28..ad590b8434 100644 --- a/src/test/test_oom.c +++ b/src/test/test_oom.c @@ -202,7 +202,7 @@ test_oom_streambuf(void *arg) { or_options_t *options = get_options_mutable(); circuit_t *c1 = NULL, *c2 = NULL, *c3 = NULL, *c4 = NULL, *c5 = NULL; - uint32_t tvms; + uint32_t tvts; int i; smartlist_t *edgeconns = smartlist_new(); const uint64_t start_ns = 1389641159 * (uint64_t)1000000000; @@ -222,6 +222,7 @@ test_oom_streambuf(void *arg) tt_int_op(buf_get_total_allocation(), OP_EQ, 0); monotime_coarse_set_mock_time_nsec(start_ns); + const uint32_t ts_start = monotime_coarse_get_stamp(); /* Start all circuits with a bit of data queued in cells */ @@ -270,22 +271,24 @@ test_oom_streambuf(void *arg) now_ns -= now_ns % 1000000000; now_ns += 1000000000; monotime_coarse_set_mock_time_nsec(now_ns); - tvms = (uint32_t) monotime_coarse_absolute_msec(); + tvts = monotime_coarse_get_stamp(); + const uint32_t diff = tvts - ts_start; + printf("\n!!!! %u\n", (unsigned) diff); - tt_int_op(circuit_max_queued_cell_age(c1, tvms), OP_EQ, 500); - tt_int_op(circuit_max_queued_cell_age(c2, tvms), OP_EQ, 490); - tt_int_op(circuit_max_queued_cell_age(c3, tvms), OP_EQ, 480); - tt_int_op(circuit_max_queued_cell_age(c4, tvms), OP_EQ, 0); + tt_int_op(circuit_max_queued_cell_age(c1, tvts), OP_EQ, 500); + tt_int_op(circuit_max_queued_cell_age(c2, tvts), OP_EQ, 490); + tt_int_op(circuit_max_queued_cell_age(c3, tvts), OP_EQ, 480); + tt_int_op(circuit_max_queued_cell_age(c4, tvts), OP_EQ, 0); - tt_int_op(circuit_max_queued_data_age(c1, tvms), OP_EQ, 390); - tt_int_op(circuit_max_queued_data_age(c2, tvms), OP_EQ, 380); - tt_int_op(circuit_max_queued_data_age(c3, tvms), OP_EQ, 0); - tt_int_op(circuit_max_queued_data_age(c4, tvms), OP_EQ, 370); + tt_int_op(circuit_max_queued_data_age(c1, tvts), OP_EQ, 390); + tt_int_op(circuit_max_queued_data_age(c2, tvts), OP_EQ, 380); + tt_int_op(circuit_max_queued_data_age(c3, tvts), OP_EQ, 0); + tt_int_op(circuit_max_queued_data_age(c4, tvts), OP_EQ, 370); - tt_int_op(circuit_max_queued_item_age(c1, tvms), OP_EQ, 500); - tt_int_op(circuit_max_queued_item_age(c2, tvms), OP_EQ, 490); - tt_int_op(circuit_max_queued_item_age(c3, tvms), OP_EQ, 480); - tt_int_op(circuit_max_queued_item_age(c4, tvms), OP_EQ, 370); + tt_int_op(circuit_max_queued_item_age(c1, tvts), OP_EQ, 500); + tt_int_op(circuit_max_queued_item_age(c2, tvts), OP_EQ, 490); + tt_int_op(circuit_max_queued_item_age(c3, tvts), OP_EQ, 480); + tt_int_op(circuit_max_queued_item_age(c4, tvts), OP_EQ, 370); tt_int_op(cell_queues_get_total_allocation(), OP_EQ, packed_cell_mem_cost() * 80); @@ -301,7 +304,7 @@ test_oom_streambuf(void *arg) smartlist_add(edgeconns, ec); } tt_int_op(buf_get_total_allocation(), OP_EQ, 4096*17*2); - tt_int_op(circuit_max_queued_item_age(c4, tvms), OP_EQ, 1000); + tt_int_op(circuit_max_queued_item_age(c4, tvts), OP_EQ, 1000); tt_int_op(cell_queues_check_size(), OP_EQ, 0); |