mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-26 12:41:05 +00:00
benchtests: Improve bench-memcpy-random
Improve the random memcpy benchmark. Double the number of tests and increase the size of the memory region to test between 32KB and 1024KB. This improves accuracy on modern cores. Clean up formatting of the frequency array. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
parent
7ca9377bab
commit
f392915d1e
@ -16,15 +16,17 @@
|
|||||||
License along with the GNU C Library; if not, see
|
License along with the GNU C Library; if not, see
|
||||||
<https://www.gnu.org/licenses/>. */
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#define MIN_PAGE_SIZE (512*1024+getpagesize())
|
#define MIN_SIZE 32768
|
||||||
|
#define MAX_SIZE (1024*1024)
|
||||||
|
#define NUM_TESTS 16384
|
||||||
|
|
||||||
|
#define MIN_PAGE_SIZE (MAX_SIZE + getpagesize())
|
||||||
#define TEST_MAIN
|
#define TEST_MAIN
|
||||||
#define TEST_NAME "memcpy"
|
#define TEST_NAME "memcpy"
|
||||||
#include "bench-string.h"
|
#include "bench-string.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "json-lib.h"
|
#include "json-lib.h"
|
||||||
|
|
||||||
#define MAX_COPIES 8192
|
|
||||||
|
|
||||||
IMPL (memcpy, 1)
|
IMPL (memcpy, 1)
|
||||||
|
|
||||||
typedef struct { uint16_t size; uint16_t freq; } freq_data_t;
|
typedef struct { uint16_t size; uint16_t freq; } freq_data_t;
|
||||||
@ -37,12 +39,12 @@ static uint8_t size_arr[SIZE_NUM];
|
|||||||
/* Frequency data for memcpy of less than 4096 bytes based on SPEC2017. */
|
/* Frequency data for memcpy of less than 4096 bytes based on SPEC2017. */
|
||||||
static freq_data_t size_freq[] =
|
static freq_data_t size_freq[] =
|
||||||
{
|
{
|
||||||
{ 32, 22320}, { 16, 9554}, { 8, 8915}, {152, 5327}, { 4, 2159}, {292, 2035},
|
{32,22320}, { 16,9554}, { 8,8915}, {152,5327}, { 4,2159}, {292,2035},
|
||||||
{ 12, 1608}, { 24, 1343}, {1152, 895}, {144, 813}, {884, 733}, {284, 721},
|
{ 12,1608}, { 24,1343}, {1152,895}, {144, 813}, {884, 733}, {284, 721},
|
||||||
{120, 661}, { 2, 649}, {882, 550}, { 5, 475}, { 7, 461}, {108, 460},
|
{120, 661}, { 2, 649}, {882, 550}, { 5, 475}, { 7, 461}, {108, 460},
|
||||||
{ 10, 361}, { 9, 361}, { 6, 334}, { 3, 326}, {464, 308}, {2048, 303},
|
{ 10, 361}, { 9, 361}, { 6, 334}, { 3, 326}, {464, 308}, {2048,303},
|
||||||
{ 1, 298}, { 64, 250}, { 11, 197}, {296, 194}, { 68, 187}, { 15, 185},
|
{ 1, 298}, { 64, 250}, { 11, 197}, {296, 194}, { 68, 187}, { 15, 185},
|
||||||
{192, 184}, {1764, 183}, { 13, 173}, {560, 126}, {160, 115}, {288, 96},
|
{192, 184}, {1764,183}, { 13, 173}, {560, 126}, {160, 115}, {288, 96},
|
||||||
{104, 96}, {1144, 83}, { 18, 80}, { 23, 78}, { 40, 77}, { 19, 68},
|
{104, 96}, {1144, 83}, { 18, 80}, { 23, 78}, { 40, 77}, { 19, 68},
|
||||||
{ 48, 63}, { 17, 57}, { 72, 54}, {1280, 51}, { 20, 49}, { 28, 47},
|
{ 48, 63}, { 17, 57}, { 72, 54}, {1280, 51}, { 20, 49}, { 28, 47},
|
||||||
{ 22, 46}, {640, 45}, { 25, 41}, { 14, 40}, { 56, 37}, { 27, 35},
|
{ 22, 46}, {640, 45}, { 25, 41}, { 14, 40}, { 56, 37}, { 27, 35},
|
||||||
@ -94,7 +96,7 @@ typedef struct
|
|||||||
uint64_t len : 16;
|
uint64_t len : 16;
|
||||||
} copy_t;
|
} copy_t;
|
||||||
|
|
||||||
static copy_t copy[MAX_COPIES];
|
static copy_t test_arr[NUM_TESTS];
|
||||||
|
|
||||||
typedef char *(*proto_t) (char *, const char *, size_t);
|
typedef char *(*proto_t) (char *, const char *, size_t);
|
||||||
|
|
||||||
@ -150,13 +152,13 @@ do_test (json_ctx_t *json_ctx, size_t max_size)
|
|||||||
|
|
||||||
/* Create a random set of copies with the given size and alignment
|
/* Create a random set of copies with the given size and alignment
|
||||||
distributions. */
|
distributions. */
|
||||||
for (i = 0; i < MAX_COPIES; i++)
|
for (i = 0; i < NUM_TESTS; i++)
|
||||||
{
|
{
|
||||||
copy[i].dst = (rand () & (max_size - 1));
|
test_arr[i].dst = (rand () & (max_size - 1));
|
||||||
copy[i].dst &= ~dst_align_arr[rand () & ALIGN_MASK];
|
test_arr[i].dst &= ~dst_align_arr[rand () & ALIGN_MASK];
|
||||||
copy[i].src = (rand () & (max_size - 1));
|
test_arr[i].src = (rand () & (max_size - 1));
|
||||||
copy[i].src &= ~src_align_arr[rand () & ALIGN_MASK];
|
test_arr[i].src &= ~src_align_arr[rand () & ALIGN_MASK];
|
||||||
copy[i].len = size_arr[rand () & SIZE_MASK];
|
test_arr[i].len = size_arr[rand () & SIZE_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
json_element_object_begin (json_ctx);
|
json_element_object_begin (json_ctx);
|
||||||
@ -164,7 +166,7 @@ do_test (json_ctx_t *json_ctx, size_t max_size)
|
|||||||
json_array_begin (json_ctx, "timings");
|
json_array_begin (json_ctx, "timings");
|
||||||
|
|
||||||
FOR_EACH_IMPL (impl, 0)
|
FOR_EACH_IMPL (impl, 0)
|
||||||
do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, copy, i);
|
do_one_test (json_ctx, impl, (char *) buf2, (char *) buf1, test_arr, i);
|
||||||
|
|
||||||
json_array_end (json_ctx);
|
json_array_end (json_ctx);
|
||||||
json_element_object_end (json_ctx);
|
json_element_object_end (json_ctx);
|
||||||
@ -193,8 +195,8 @@ test_main (void)
|
|||||||
json_array_end (&json_ctx);
|
json_array_end (&json_ctx);
|
||||||
|
|
||||||
json_array_begin (&json_ctx, "results");
|
json_array_begin (&json_ctx, "results");
|
||||||
for (int i = 4; i <= 512; i = i * 2)
|
for (int i = MIN_SIZE; i <= MAX_SIZE; i = i * 2)
|
||||||
do_test (&json_ctx, i * 1024);
|
do_test (&json_ctx, i);
|
||||||
|
|
||||||
json_array_end (&json_ctx);
|
json_array_end (&json_ctx);
|
||||||
json_attr_object_end (&json_ctx);
|
json_attr_object_end (&json_ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user