int test_main (void) { json_ctx_t json_ctx; size_t i; test_init (); json_init (&json_ctx, 0, stdout); json_document_begin (&json_ctx); json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); json_attr_object_begin (&json_ctx, "functions"); json_attr_object_begin (&json_ctx, TEST_NAME); json_attr_string (&json_ctx, "bench-variant", "default"); json_array_begin (&json_ctx, "ifuncs"); FOR_EACH_IMPL (impl, 0) json_element_string (&json_ctx, impl->name); json_array_end (&json_ctx); json_array_begin (&json_ctx, "results"); for (i = 1; i < 32; ++i) { do_test (&json_ctx, CHARBYTES * i, CHARBYTES * i, i, MIDCHAR, 0); do_test (&json_ctx, CHARBYTES * i, CHARBYTES * i, i, MIDCHAR, 1); do_test (&json_ctx, CHARBYTES * i, CHARBYTES * i, i, MIDCHAR, -1); } for (i = 1; i < 10 + CHARBYTESLOG; ++i) { do_test (&json_ctx, 0, 0, 2 << i, MIDCHAR, 0); do_test (&json_ctx, 0, 0, 2 << i, LARGECHAR, 0); do_test (&json_ctx, 0, 0, 2 << i, MIDCHAR, 1); do_test (&json_ctx, 0, 0, 2 << i, LARGECHAR, 1); do_test (&json_ctx, 0, 0, 2 << i, MIDCHAR, -1); do_test (&json_ctx, 0, 0, 2 << i, LARGECHAR, -1); do_test (&json_ctx, 0, CHARBYTES * i, 2 << i, MIDCHAR, 1); do_test (&json_ctx, CHARBYTES * i, CHARBYTES * (i + 1), 2 << i, LARGECHAR, 1); } for (i = 1; i < 8; ++i) { do_test (&json_ctx, CHARBYTES * i, 2 * CHARBYTES * i, 8 << i, MIDCHAR, 0); do_test (&json_ctx, 2 * CHARBYTES * i, CHARBYTES * i, 8 << i, LARGECHAR, 0); do_test (&json_ctx, CHARBYTES * i, 2 * CHARBYTES * i, 8 << i, MIDCHAR, 1); do_test (&json_ctx, 2 * CHARBYTES * i, CHARBYTES * i, 8 << i, LARGECHAR, 1); do_test (&json_ctx, CHARBYTES * i, 2 * CHARBYTES * i, 8 << i, MIDCHAR, -1); do_test (&json_ctx, 2 * CHARBYTES * i, CHARBYTES * i, 8 << i, LARGECHAR, -1); } json_array_end (&json_ctx); json_attr_object_end (&json_ctx); json_attr_object_end (&json_ctx); json_document_end (&json_ctx); return ret; }
int test_main (void) { json_ctx_t json_ctx; test_init (); json_init (&json_ctx, 0, stdout); json_document_begin (&json_ctx); json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); json_attr_object_begin (&json_ctx, "functions"); json_attr_object_begin (&json_ctx, "memmove"); json_attr_string (&json_ctx, "bench-variant", "walk"); json_array_begin (&json_ctx, "ifuncs"); FOR_EACH_IMPL (impl, 0) json_element_string (&json_ctx, impl->name); json_array_end (&json_ctx); json_array_begin (&json_ctx, "results"); /* Non-overlapping buffers. */ for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1) { do_test (&json_ctx, i, false); do_test (&json_ctx, i + 1, false); } /* Overlapping buffers. */ for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1) { do_test (&json_ctx, i, true); do_test (&json_ctx, i + 1, true); } json_array_end (&json_ctx); json_attr_object_end (&json_ctx); json_attr_object_end (&json_ctx); json_document_end (&json_ctx); return ret; }
int test_main (void) { json_ctx_t json_ctx; size_t i; test_init (); json_init (&json_ctx, 0, stdout); json_document_begin (&json_ctx); json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); json_attr_object_begin (&json_ctx, "functions"); json_attr_object_begin (&json_ctx, "memcpy"); json_attr_string (&json_ctx, "bench-variant", "walk"); json_array_begin (&json_ctx, "ifuncs"); FOR_EACH_IMPL (impl, 0) json_element_string (&json_ctx, impl->name); json_array_end (&json_ctx); json_array_begin (&json_ctx, "results"); for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1) { /* Test length alignments from 0-16 bytes. */ for (int j = 0; j < 8; j++) { do_test (&json_ctx, i + j); do_test (&json_ctx, i + 16 - j); } } json_array_end (&json_ctx); json_attr_object_end (&json_ctx); json_attr_object_end (&json_ctx); json_document_end (&json_ctx); return ret; }
int main (int argc, char **argv) { timing_t cur; size_t iters = 0, num_threads = 1; unsigned long res; json_ctx_t json_ctx; double d_total_s, d_total_i; struct sigaction act; if (argc == 1) num_threads = 1; else if (argc == 2) { long ret; errno = 0; ret = strtol(argv[1], NULL, 10); if (errno || ret == 0) usage(argv[0]); num_threads = ret; } else usage(argv[0]); init_random_values (); json_init (&json_ctx, 0, stdout); json_document_begin (&json_ctx); json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); json_attr_object_begin (&json_ctx, "functions"); json_attr_object_begin (&json_ctx, "malloc"); json_attr_object_begin (&json_ctx, ""); TIMING_INIT (res); (void) res; memset (&act, 0, sizeof (act)); act.sa_handler = &alarm_handler; sigaction (SIGALRM, &act, NULL); alarm (BENCHMARK_DURATION); cur = do_benchmark (num_threads, &iters); struct rusage usage; getrusage(RUSAGE_SELF, &usage); d_total_s = cur; d_total_i = iters; json_attr_double (&json_ctx, "duration", d_total_s); json_attr_double (&json_ctx, "iterations", d_total_i); json_attr_double (&json_ctx, "time_per_iteration", d_total_s / d_total_i); json_attr_double (&json_ctx, "max_rss", usage.ru_maxrss); json_attr_double (&json_ctx, "threads", num_threads); json_attr_double (&json_ctx, "min_size", MIN_ALLOCATION_SIZE); json_attr_double (&json_ctx, "max_size", MAX_ALLOCATION_SIZE); json_attr_double (&json_ctx, "random_seed", RAND_SEED); json_attr_object_end (&json_ctx); json_attr_object_end (&json_ctx); json_attr_object_end (&json_ctx); json_document_end (&json_ctx); return 0; }
static int test_main (void) { json_ctx_t json_ctx; size_t i; test_init (); json_init (&json_ctx, 0, stdout); json_document_begin (&json_ctx); json_attr_string (&json_ctx, "timing_type", TIMING_TYPE); json_attr_object_begin (&json_ctx, "functions"); json_attr_object_begin (&json_ctx, "memmove"); json_attr_string (&json_ctx, "bench-variant", "default"); json_array_begin (&json_ctx, "ifuncs"); FOR_EACH_IMPL (impl, 0) json_element_string (&json_ctx, impl->name); json_array_end (&json_ctx); json_array_begin (&json_ctx, "results"); for (i = 0; i < 14; ++i) { do_test (&json_ctx, 0, 32, 1 << i); do_test (&json_ctx, 32, 0, 1 << i); do_test (&json_ctx, 0, i, 1 << i); do_test (&json_ctx, i, 0, 1 << i); } for (i = 0; i < 32; ++i) { do_test (&json_ctx, 0, 32, i); do_test (&json_ctx, 32, 0, i); do_test (&json_ctx, 0, i, i); do_test (&json_ctx, i, 0, i); } for (i = 3; i < 32; ++i) { if ((i & (i - 1)) == 0) continue; do_test (&json_ctx, 0, 32, 16 * i); do_test (&json_ctx, 32, 0, 16 * i); do_test (&json_ctx, 0, i, 16 * i); do_test (&json_ctx, i, 0, 16 * i); } for (i = 32; i < 64; ++i) { do_test (&json_ctx, 0, 0, 32 * i); do_test (&json_ctx, i, 0, 32 * i); do_test (&json_ctx, 0, i, 32 * i); do_test (&json_ctx, i, i, 32 * i); } json_array_end (&json_ctx); json_attr_object_end (&json_ctx); json_attr_object_end (&json_ctx); json_document_end (&json_ctx); return ret; }