Loading...
--- libmalloc/libmalloc-715.100.22/tests/perf_realloc.c
+++ libmalloc/libmalloc-374.60.3/tests/perf_realloc.c
@@ -1,13 +1,8 @@
#include <stdlib.h>
+#include <mach/vm_page_size.h>
#include <../src/internal.h>
#include <darwintest.h>
-
-#if !MALLOC_TARGET_EXCLAVES
-#include <mach/vm_page_size.h>
#include <perfcheck_keys.h>
-#else
-#include <time.h>
-#endif // !MALLOC_TARGET_EXCLAVES
#pragma mark -
#pragma mark Helper code
@@ -28,7 +23,6 @@
realloc_by_amount(const char *base_metric_name, size_t size, ssize_t amount,
bool amount_is_random)
{
-#if !MALLOC_TARGET_EXCLAVES
if (amount_is_random) {
snprintf(name, MAX_NAME_SIZE, amount >= 0 ?
"%s_from_%llu_up_random" : "%s_from_%llu_down_random",
@@ -38,53 +32,27 @@
"%s_from_%llu_up_%ld" : "%s_from_%llu_down_%ld",
base_metric_name, (uint64_t)size, labs(amount));
}
-#endif // !MALLOC_TARGET_EXCLAVES
uint64_t total_time = 0;
int count = 0;
-
-#if !MALLOC_TARGET_EXCLAVES
dt_stat_time_t s = dt_stat_time_create(name);
dt_stat_set_variable((dt_stat_t)s, "size (bytes)", (unsigned int)size);
dt_stat_set_variable((dt_stat_t)s, "amount (bytes)", (int)amount);
dt_stat_token now = dt_stat_time_begin(s);
-#endif // !MALLOC_TARGET_EXCLAVES
for (;;) {
void *ptr = malloc(size);
T_QUIET; T_ASSERT_NOTNULL(ptr, "malloc for size %llu failed", (uint64_t)size);
-#if MALLOC_TARGET_EXCLAVES
- struct timespec start, end;
- int rc_start = clock_gettime(CLOCK_MONOTONIC_RAW, &start);
- ptr = realloc(ptr, size + amount);
- int rc_end = clock_gettime(CLOCK_MONOTONIC_RAW, &end);
-
- const uint64_t _NSEC_PER_SEC = 1000000000ull;
- uint64_t start_nsec = start.tv_sec * _NSEC_PER_SEC + start.tv_nsec;
- uint64_t end_nsec = end.tv_sec * _NSEC_PER_SEC + end.tv_nsec;
- total_time += end_nsec - start_nsec;
-#else
dt_stat_token start = dt_stat_time_begin(s);
ptr = realloc(ptr, size + amount);
dt_stat_token end = dt_stat_time_begin(s);
- total_time += end - start;
-#endif // MALLOC_TARGET_EXCLAVES
-
T_QUIET; T_ASSERT_NOTNULL(ptr,
"realloc from size %llu to size %llu failed", (uint64_t)size,
(uint64_t)(size + amount));
+ total_time += end - start;
free(ptr);
-#if MALLOC_TARGET_EXCLAVES
- // On exclaves, run this test for the very arbitrary 10ms, or at
- // least 5 loops
- if (++count >= 5 && total_time >= (_NSEC_PER_SEC / 100)) {
- T_LOG("Ran realloc test for %d iterations, average time %llu",
- count, total_time / count);
- break;
- }
-#else
if (++count >= NUMBER_OF_SAMPLES_FOR_BATCH(s)) {
// Discard outliers or the test won't converge -- this should
// be done in libdarwintest
@@ -97,12 +65,9 @@
break;
}
}
-#endif // MALLOC_TARGET_EXCLAVES
}
-#if !MALLOC_TARGET_EXCLAVES
dt_stat_finalize(s);
-#endif // !MALLOC_TARGET_EXCLAVES
}
// Times a set of size adjustments from a given base.
@@ -179,15 +144,13 @@
#pragma mark Tests for realloc()
T_DECL(realloc_perf_base, "realloc without nano",
- T_META_TAG_PERF, T_META_TAG_VM_NOT_PREFERRED,
- T_META_ENVVAR("MallocNanoZone=0"))
+ T_META_TAG_PERF, T_META_ENVVAR("MallocNanoZone=0"))
{
realloc_tests("NoNano", false);
}
T_DECL(realloc_perf_nanov2, "realloc with nanoV2",
- T_META_TAG_PERF, T_META_TAG_VM_NOT_PREFERRED,
- T_META_ENVVAR("MallocNanoZone=V2"))
+ T_META_TAG_PERF, T_META_ENVVAR("MallocNanoZone=V2"))
{
#if CONFIG_NANOZONE
realloc_tests("Nanov2", true);