]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/sorter/debug/retros.c
Doc: Documented growing arrays, generic allocators and related things
[libucw.git] / ucw / sorter / debug / retros.c
index 7bb692f6bead3094d3d3b06a6ea8a9088d3a0042..7325de7529721d1af36c99a3706fd9b1fc8009a1 100644 (file)
@@ -4,10 +4,11 @@
  *  (c) 2007--2008 Martin Mares <mj@ucw.cz>
  */
 
-#include "sherlock/sherlock.h"
-#include "ucw/getopt.h"
-#include "ucw/md5.h"
-#include "ucw/heap.h"
+#include <ucw/lib.h>
+#include <ucw/getopt.h>
+#include <ucw/md5.h>
+#include <ucw/heap.h>
+#include <ucw/time.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -51,13 +52,13 @@ static int comp_ind(const void *x, const void *y)
 #define ASORT_ELT(i) a[i].key
 #define ASORT_SWAP(i,j) do { struct elt t=a[i]; a[i]=a[j]; a[j]=t; } while (0)
 #define ASORT_EXTRA_ARGS , struct elt *a
-#include "ucw/sorter/array-simple.h"
+#include <ucw/sorter/array-simple.h>
 
 #define ASORT_PREFIX(x) asi_##x
 #define ASORT_KEY_TYPE u32
 #define ASORT_ELT(i) ind[i]->key
 #define ASORT_SWAP(i,j) do { struct elt *t=ind[i]; ind[i]=ind[j]; ind[j]=t; } while (0)
-#include "ucw/sorter/array-simple.h"
+#include <ucw/sorter/array-simple.h>
 
 static void r1_sort(void)
 {
@@ -622,7 +623,7 @@ static void heapsort(void)
   HEAP_INIT(struct elt, heap, n, H_LESS, HEAP_SWAP);
   uns nn = n;
   while (nn)
-    HEAP_DELMIN(struct elt, heap, nn, H_LESS, HEAP_SWAP);
+    HEAP_DELETE_MIN(struct elt, heap, nn, H_LESS, HEAP_SWAP);
 #undef H_LESS
 }
 
@@ -633,7 +634,7 @@ static void heapsort_ind(void)
   HEAP_INIT(struct elt *, heap, n, H_LESS, HEAP_SWAP);
   uns nn = n;
   while (nn)
-    HEAP_DELMIN(struct elt *, heap, nn, H_LESS, HEAP_SWAP);
+    HEAP_DELETE_MIN(struct elt *, heap, nn, H_LESS, HEAP_SWAP);
 #undef H_LESS
 }
 
@@ -719,7 +720,7 @@ int main(int argc, char **argv)
   for (uns i=0; i<n; i++)
     array0[i] = array1[i] = (struct elt) { 0 };
 
-  log(L_INFO, "Testing with %u elements", n);
+  msg(L_INFO, "Testing with %u elements", n);
 
   mk_ary();
   timestamp_t timer;
@@ -736,9 +737,9 @@ int main(int argc, char **argv)
        ary[j] = alt[j];
 #endif
     }
-  log(L_DEBUG, "memcpy: %d", get_timer(&timer)/10);
+  msg(L_DEBUG, "memcpy: %d", get_timer(&timer)/10);
 
-#define BENCH(type, name, func) mk_##type(); init_timer(&timer); func; log(L_DEBUG, name ": %d", get_timer(&timer)); chk_##type()
+#define BENCH(type, name, func) mk_##type(); init_timer(&timer); func; msg(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));