2 * UCW Library -- Universal Array Sorter Test and Benchmark
4 * (c) 2003 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
15 #define N 4000037 /* a prime */
22 static struct elt array[N];
24 #define ASORT_KEY_TYPE u32
25 #define ASORT_ELT(i) array[i].key
26 #define ASORT_SWAP(i,j) do { struct elt e=array[j]; array[j]=array[i]; array[i]=e; } while(0)
28 static void generate(void)
37 ASORT_ELT(i) = (i ? ASORT_ELT(i-1)+1944833754 : 3141592) % N;
41 static void check(void)
45 if (ASORT_ELT(i) != i)
46 printf("error at pos %d: %08x != %08x\n", i, ASORT_ELT(i), i);
49 static int qs_comp(const struct elt *X, const struct elt *Y)
53 else if (X->key > Y->key)
59 #define ASORT_PREFIX(x) as_##x
60 #include "lib/arraysort.h"
68 qsort(array, N, sizeof(array[0]), (int (*)(const void *, const void *)) qs_comp);
69 printf("qsort: %d ms\n", get_timer(&timer));
74 printf("asort: %d ms\n", get_timer(&timer));