diff options
Diffstat (limited to 'benchtests')
-rw-r--r-- | benchtests/bench-memcpy-walk.c | 14 | ||||
-rw-r--r-- | benchtests/bench-memmove-walk.c | 15 | ||||
-rw-r--r-- | benchtests/bench-memset-walk.c | 4 |
3 files changed, 12 insertions, 21 deletions
diff --git a/benchtests/bench-memcpy-walk.c b/benchtests/bench-memcpy-walk.c index 69d467d3fe..5b563411ad 100644 --- a/benchtests/bench-memcpy-walk.c +++ b/benchtests/bench-memcpy-walk.c @@ -47,26 +47,22 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, size_t len) { - size_t i, iters = MIN_PAGE_SIZE / len; + size_t i = 0; timing_t start, stop, cur; char *dst_end = dst + MIN_PAGE_SIZE - len; char *src_end = src + MIN_PAGE_SIZE - len; TIMING_NOW (start); - /* Copy the entire buffer back and forth, LEN at a time. */ - for (i = 0; i < iters && dst_end >= dst && src <= src_end; src++, dst_end--) - { - CALL (impl, dst_end, src, len); - CALL (impl, src, dst_end, len); - i += 2; - } + /* Copy the entire buffer backwards, LEN at a time. */ + for (; src_end >= src && dst_end >= dst; src_end -= len, dst_end -= len, i++) + CALL (impl, src_end, dst_end, len); TIMING_NOW (stop); TIMING_DIFF (cur, start, stop); /* Get time taken per function call. */ - json_element_double (json_ctx, (double) cur * len / i); + json_element_double (json_ctx, (double) cur / i); } static void diff --git a/benchtests/bench-memmove-walk.c b/benchtests/bench-memmove-walk.c index 54dcd64292..969ddd94a2 100644 --- a/benchtests/bench-memmove-walk.c +++ b/benchtests/bench-memmove-walk.c @@ -47,26 +47,22 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, size_t len) { - size_t i, iters = MIN_PAGE_SIZE / len; + size_t i = 0; timing_t start, stop, cur; char *dst_end = dst + MIN_PAGE_SIZE - len; char *src_end = src + MIN_PAGE_SIZE - len; TIMING_NOW (start); - /* Copy the entire buffer back and forth, LEN at a time. */ - for (i = 0; i < iters && dst_end >= dst && src <= src_end; src++, dst_end--) - { - CALL (impl, dst_end, src, len); - CALL (impl, src, dst_end, len); - i += 2; - } + /* Copy the entire buffer backwards, LEN at a time. */ + for (; src_end >= src && dst <= dst_end; dst += len, src_end -= len, i++) + CALL (impl, dst, src_end, len); TIMING_NOW (stop); TIMING_DIFF (cur, start, stop); /* Get time taken per function call. */ - json_element_double (json_ctx, (double) cur * len / i); + json_element_double (json_ctx, (double) cur / i); } static void @@ -79,7 +75,6 @@ do_test (json_ctx_t *json_ctx, size_t len, bool overlap) if (overlap) buf2 = buf1; - /* First the non-overlapping moves. */ FOR_EACH_IMPL (impl, 0) do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, len); diff --git a/benchtests/bench-memset-walk.c b/benchtests/bench-memset-walk.c index 59d2626f46..80fbe092b8 100644 --- a/benchtests/bench-memset-walk.c +++ b/benchtests/bench-memset-walk.c @@ -66,14 +66,14 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, CHAR *s_end, timing_t start, stop, cur; TIMING_NOW (start); - for (i = 0; i < iters && s <= s_end; s++, i++) + for (i = 0; i < iters && s <= s_end; s_end -= n, i++) CALL (impl, s, c, n); TIMING_NOW (stop); TIMING_DIFF (cur, start, stop); /* Get time taken per function call. */ - json_element_double (json_ctx, (double) cur * n / i); + json_element_double (json_ctx, (double) cur / i); } static void |