X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=debug%2Fsorter%2Fretros.c;h=e85dfe853934e528ce344d2157bc27748c0f53ff;hb=aafbea40b7613274180c8bab60012a0322f8d7dd;hp=b0de3a824e91b53848ee9f9ca5064cdfd6e86c45;hpb=8c661b20faa518f211d54b59ede9127e3b633914;p=libucw.git diff --git a/debug/sorter/retros.c b/debug/sorter/retros.c index b0de3a82..e85dfe85 100644 --- a/debug/sorter/retros.c +++ b/debug/sorter/retros.c @@ -1,5 +1,7 @@ /* - * An experiment with sorting algorithms + * Experiments with various sorting algorithms + * + * (c) 2007 Martin Mares */ #include "sherlock/sherlock.h" @@ -23,25 +25,12 @@ static u32 sum; 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) @@ -198,8 +187,8 @@ static void r1c_sse_sort(void) 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)); @@ -708,7 +697,8 @@ int main(int argc, char **argv) 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 @@ -721,9 +711,9 @@ int main(int argc, char **argv) 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));