Blame benchtests/bench-memcpy-large.c

Packit Service 82fcde
/* Measure memcpy functions with large data sizes.
Packit Service 82fcde
   Copyright (C) 2016-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#ifndef MEMCPY_RESULT
Packit Service 82fcde
# define MEMCPY_RESULT(dst, len) dst
Packit Service 82fcde
# define START_SIZE (64 * 1024)
Packit Service 82fcde
# define MIN_PAGE_SIZE (getpagesize () + 32 * 1024 * 1024)
Packit Service 82fcde
# define TEST_MAIN
Packit Service 82fcde
# define TEST_NAME "memcpy"
Packit Service 82fcde
# define TIMEOUT (20 * 60)
Packit Service 82fcde
# include "bench-string.h"
Packit Service 82fcde
Packit Service 82fcde
IMPL (memcpy, 1)
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#include "json-lib.h"
Packit Service 82fcde
Packit Service 82fcde
typedef char *(*proto_t) (char *, const char *, size_t);
Packit Service 82fcde
Packit Service 82fcde
static void
Packit Service 82fcde
do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src,
Packit Service 82fcde
	     size_t len)
Packit Service 82fcde
{
Packit Service 82fcde
  size_t i, iters = 16;
Packit Service 82fcde
  timing_t start, stop, cur;
Packit Service 82fcde
Packit Service 82fcde
  TIMING_NOW (start);
Packit Service 82fcde
  for (i = 0; i < iters; ++i)
Packit Service 82fcde
    {
Packit Service 82fcde
      CALL (impl, dst, src, len);
Packit Service 82fcde
    }
Packit Service 82fcde
  TIMING_NOW (stop);
Packit Service 82fcde
Packit Service 82fcde
  TIMING_DIFF (cur, start, stop);
Packit Service 82fcde
Packit Service 82fcde
  json_element_double (json_ctx, (double) cur / (double) iters);
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
static void
Packit Service 82fcde
do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
Packit Service 82fcde
{
Packit Service 82fcde
  size_t i, j;
Packit Service 82fcde
  char *s1, *s2;
Packit Service 82fcde
Packit Service 82fcde
  align1 &= 63;
Packit Service 82fcde
  if (align1 + len >= page_size)
Packit Service 82fcde
    return;
Packit Service 82fcde
Packit Service 82fcde
  align2 &= 63;
Packit Service 82fcde
  if (align2 + len >= page_size)
Packit Service 82fcde
    return;
Packit Service 82fcde
Packit Service 82fcde
  s1 = (char *) (buf1 + align1);
Packit Service 82fcde
  s2 = (char *) (buf2 + align2);
Packit Service 82fcde
Packit Service 82fcde
  for (i = 0, j = 1; i < len; i++, j += 23)
Packit Service 82fcde
    s1[i] = j;
Packit Service 82fcde
Packit Service 82fcde
  json_element_object_begin (json_ctx);
Packit Service 82fcde
  json_attr_uint (json_ctx, "length", (double) len);
Packit Service 82fcde
  json_attr_uint (json_ctx, "align1", (double) align1);
Packit Service 82fcde
  json_attr_uint (json_ctx, "align2", (double) align2);
Packit Service 82fcde
  json_array_begin (json_ctx, "timings");
Packit Service 82fcde
Packit Service 82fcde
  FOR_EACH_IMPL (impl, 0)
Packit Service 82fcde
    do_one_test (json_ctx, impl, s2, s1, len);
Packit Service 82fcde
Packit Service 82fcde
  json_array_end (json_ctx);
Packit Service 82fcde
  json_element_object_end (json_ctx);
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
int
Packit Service 82fcde
test_main (void)
Packit Service 82fcde
{
Packit Service 82fcde
  json_ctx_t json_ctx;
Packit Service 82fcde
  size_t i;
Packit Service 82fcde
Packit Service 82fcde
  test_init ();
Packit Service 82fcde
Packit Service 82fcde
  json_init (&json_ctx, 0, stdout);
Packit Service 82fcde
Packit Service 82fcde
  json_document_begin (&json_ctx);
Packit Service 82fcde
  json_attr_string (&json_ctx, "timing_type", TIMING_TYPE);
Packit Service 82fcde
Packit Service 82fcde
  json_attr_object_begin (&json_ctx, "functions");
Packit Service 82fcde
  json_attr_object_begin (&json_ctx, TEST_NAME);
Packit Service 82fcde
  json_attr_string (&json_ctx, "bench-variant", "large");
Packit Service 82fcde
Packit Service 82fcde
  json_array_begin (&json_ctx, "ifuncs");
Packit Service 82fcde
  FOR_EACH_IMPL (impl, 0)
Packit Service 82fcde
    json_element_string (&json_ctx, impl->name);
Packit Service 82fcde
  json_array_end (&json_ctx);
Packit Service 82fcde
Packit Service 82fcde
  json_array_begin (&json_ctx, "results");
Packit Service 82fcde
  for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
Packit Service 82fcde
    {
Packit Service 82fcde
      do_test (&json_ctx, 0, 0, i + 7);
Packit Service 82fcde
      do_test (&json_ctx, 0, 3, i + 15);
Packit Service 82fcde
      do_test (&json_ctx, 3, 0, i + 31);
Packit Service 82fcde
      do_test (&json_ctx, 3, 5, i + 63);
Packit Service 82fcde
    }
Packit Service 82fcde
Packit Service 82fcde
  json_array_end (&json_ctx);
Packit Service 82fcde
  json_attr_object_end (&json_ctx);
Packit Service 82fcde
  json_attr_object_end (&json_ctx);
Packit Service 82fcde
  json_document_end (&json_ctx);
Packit Service 82fcde
Packit Service 82fcde
  return ret;
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
#include <support/test-driver.c>