static struct elt *alloc_elts(uns n)
{
-#if 0
- return xmalloc(n * sizeof(struct elt));
-#else
- uns len = ALIGN_TO(n * sizeof(struct elt), PAGE_SIZE);
- void *p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
- ASSERT(p != MAP_FAILED);
- return p;
-#endif
+ return big_alloc(n * sizeof(struct elt));
}
static void free_elts(struct elt *a, uns n)
{
-#if 0
- xfree(a);
- (void) n;
-#else
- uns len = ALIGN_TO(n * sizeof(struct elt), PAGE_SIZE);
- munmap(a, len);
-#endif
+ big_free(a, n * sizeof(struct elt));
}
static int comp(const void *x, const void *y)
struct elt *ptrs[256], *x, *lim;
ASSERT(sizeof(struct elt) == 16);
- ASSERT(!((addr_int_t)alt & 15));
- ASSERT(!((addr_int_t)ary & 15));
+ ASSERT(!((uintptr_t)alt & 15));
+ ASSERT(!((uintptr_t)ary & 15));
x = ary; lim = ary + n;
bzero(cnt, sizeof(cnt));
array0[i] = array1[i] = (struct elt) { 0 };
mk_ary();
- init_timer();
+ timestamp_t timer;
+ init_timer(&timer);
for (uns i=0; i<5; i++)
{
#if 1
ary[j] = alt[j];
#endif
}
- log(L_DEBUG, "memcpy: %d", get_timer()/10);
+ log(L_DEBUG, "memcpy: %d", get_timer(&timer)/10);
-#define BENCH(type, name, func) mk_##type(); init_timer(); func; log(L_DEBUG, name ": %d", get_timer()); chk_##type()
+#define BENCH(type, name, func) mk_##type(); init_timer(&timer); func; log(L_DEBUG, name ": %d", get_timer(&timer)); chk_##type()
//BENCH(ary, "qsort", qsort(ary, n, sizeof(struct elt), comp));
//BENCH(ary, "arraysort", as_sort(n, ary));