Skip to content

Commit

Permalink
Reallocate buffers for every run in strlen
Browse files Browse the repository at this point in the history
Try and avoid influencing performance of neighbouring functions.
  • Loading branch information
siddhesh committed Aug 16, 2018
1 parent 953a5a4 commit 34f86d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2018-08-16 Siddhesh Poyarekar <[email protected]>

* benchtests/bench-strlen.c (do_test): Allocate buffers before
every strlen call.

* benchtests/bench-strlen.c: Print performance numbers in json.

2018-08-16 Rajalakshmi Srinivasaraghavan <[email protected]>
Expand Down
17 changes: 10 additions & 7 deletions benchtests/bench-strlen.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,23 @@ do_test (json_ctx_t *json_ctx, size_t align, size_t len)
if (align + sizeof(CHAR) * len >= page_size)
return;

CHAR *buf = (CHAR *) (buf1);

for (i = 0; i < len; ++i)
buf[align + i] = 1 + 11111 * i % MAX_CHAR;
buf[align + len] = 0;

json_element_object_begin (json_ctx);
json_attr_uint (json_ctx, "length", len);
json_attr_uint (json_ctx, "alignment", align);
json_array_begin (json_ctx, "timings");


FOR_EACH_IMPL (impl, 0)
do_one_test (json_ctx, impl, (CHAR *) (buf + align), len);
{
CHAR *buf = (CHAR *) (buf1);

for (i = 0; i < len; ++i)
buf[align + i] = 1 + 11111 * i % MAX_CHAR;
buf[align + len] = 0;

do_one_test (json_ctx, impl, (CHAR *) (buf + align), len);
alloc_bufs ();
}

json_array_end (json_ctx);
json_element_object_end (json_ctx);
Expand Down

0 comments on commit 34f86d6

Please sign in to comment.