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.
16 #define N 4000037 /* a prime */
23 static struct elt array[N];
25 #define ASORT_KEY_TYPE u32
26 #define ASORT_ELT(i) array[i].key
27 #define ASORT_SWAP(i,j) do { struct elt e=array[j]; array[j]=array[i]; array[i]=e; } while(0)
29 static void generate(void)
38 ASORT_ELT(i) = (i ? ASORT_ELT(i-1)+1944833754 : 3141592) % N;
42 static int errors = 0;
44 static void check(void)
48 if (ASORT_ELT(i) != i)
50 printf("error at pos %d: %08x != %08x\n", i, ASORT_ELT(i), i);
55 static int qs_comp(const struct elt *X, const struct elt *Y)
59 else if (X->key > Y->key)
65 #define ASORT_PREFIX(x) as_##x
66 #include <ucw/sorter/array-simple.h>
74 qsort(array, N, sizeof(array[0]), (int (*)(const void *, const void *)) qs_comp);
75 printf("qsort: %d ms\n", get_timer(&timer));
80 printf("asort: %d ms\n", get_timer(&timer));