void unit_test_jit_fragment_tree() { uint i; bb_node_t *node_list[FRAGMENT_TREE_TEST_NODE_COUNT]; /* N.B.: may contain NULLs */ print_file(STDERR, "test DGC fragment tree: "); dynamo_options.opt_jit = true; fragment_tree = fragment_tree_create(); set_random_seed((uint) query_time_millis()); for (i = 0; i < 3; i++) { print_file(STDERR, "pass %d... ", i+1); unit_test_insert_random_nodes(node_list, FRAGMENT_TREE_TEST_NODE_COUNT); unit_test_remove_random_spans(node_list, FRAGMENT_TREE_TEST_NODE_COUNT); fragment_tree_clear(fragment_tree); unit_test_churn_narrow_span(node_list, FRAGMENT_TREE_TEST_NODE_COUNT); fragment_tree_clear(fragment_tree); } fragment_tree_destroy(fragment_tree); print_file(STDERR, "\n"); }
static void our_memcpy_vs_libc(void) { /* Compare our memcpy with libc memcpy. * XXX: Should compare on more sizes, especially small ones. */ size_t alloc_size = 20 * 1024; int loop_count = 100 * 1000; void *src = global_heap_alloc(alloc_size HEAPACCT(ACCT_OTHER)); void *dst = global_heap_alloc(alloc_size HEAPACCT(ACCT_OTHER)); int i; memcpy_t glibc_memcpy = (memcpy_t) dlsym(RTLD_NEXT, "memcpy"); uint64 our_memcpy_start, our_memcpy_end, our_memcpy_time; uint64 libc_memcpy_start, libc_memcpy_end, libc_memcpy_time; memset(src, -1, alloc_size); memset(dst, 0, alloc_size); our_memcpy_start = query_time_millis(); for (i = 0; i < loop_count; i++) { memcpy(src, dst, alloc_size); } our_memcpy_end = query_time_millis(); libc_memcpy_start = query_time_millis(); for (i = 0; i < loop_count; i++) { glibc_memcpy(src, dst, alloc_size); } libc_memcpy_end = query_time_millis(); global_heap_free(src, alloc_size HEAPACCT(ACCT_OTHER)); global_heap_free(dst, alloc_size HEAPACCT(ACCT_OTHER)); our_memcpy_time = our_memcpy_end - our_memcpy_start; libc_memcpy_time = libc_memcpy_end - libc_memcpy_start; print_file(STDERR, "our_memcpy_time: "UINT64_FORMAT_STRING"\n", our_memcpy_time); print_file(STDERR, "libc_memcpy_time: "UINT64_FORMAT_STRING"\n", libc_memcpy_time); /* We could assert that we're not too much slower, but that's a recipe for * flaky failures when the suite is run on shared VMs or in parallel. */ }
static bool unit_test_insert_random_node(bb_node_t **node_list, app_pc random_base, uint random_span, uint index) { app_pc random_start = unit_test_get_random_pc(random_base, random_span); app_pc random_end = unit_test_get_random_pc(random_start + 2, 0x40); if (fragment_tree_lookup(fragment_tree, random_start, random_end) == NULL) { node_list[index] = fragment_tree_insert(fragment_tree, random_start, random_end); return true; } else { set_random_seed((uint) query_time_millis()); return false; } }