]> mj.ucw.cz Git - libucw.git/blobdiff - debug/sorter/retros.c
Merge with git+ssh://git.ucw.cz/projects/sherlock/GIT/sherlock.git
[libucw.git] / debug / sorter / retros.c
index b0de3a824e91b53848ee9f9ca5064cdfd6e86c45..e85dfe853934e528ce344d2157bc27748c0f53ff 100644 (file)
@@ -1,5 +1,7 @@
 /*
- *  An experiment with sorting algorithms
+ *  Experiments with various sorting algorithms
+ *
+ *  (c) 2007 Martin Mares <mj@ucw.cz>
  */
 
 #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));