]> mj.ucw.cz Git - libucw.git/blobdiff - lib/sorter/sort-test.c
XML: Implemented a merger of element's contents.
[libucw.git] / lib / sorter / sort-test.c
index 92f8d9b762d861574d9b13972affe5e8a15f0432..e7d5873020d2bb527e2ac0efb312bbe5ff0b8e4f 100644 (file)
 #include <fcntl.h>
 #include <unistd.h>
 
 #include <fcntl.h>
 #include <unistd.h>
 
+/*** A hack for overriding radix-sorter configuration ***/
+
+#ifdef FORCE_RADIX_BITS
+#undef CONFIG_UCW_RADIX_SORTER_BITS
+#define CONFIG_UCW_RADIX_SORTER_BITS FORCE_RADIX_BITS
+#endif
+
 /*** Time measurement ***/
 
 static timestamp_t timer;
 /*** Time measurement ***/
 
 static timestamp_t timer;
@@ -390,7 +397,7 @@ static int s5_gen(struct s5_pair *p)
 {
   if (s5_j >= s5_N)
     {
 {
   if (s5_j >= s5_N)
     {
-      if (s5_i >= s5_N-1)
+      if (!s5_N || s5_i >= s5_N-1)
        return 0;
       s5_j = 0;
       s5_i++;
        return 0;
       s5_j = 0;
       s5_i++;
@@ -468,7 +475,7 @@ static int s5_presort(struct fastbuf *dest, void *buf, size_t bufsize)
     n++;
   if (!n)
     return 0;
     n++;
   if (!n)
     return 0;
-  s5p_sort(a, n, NULL, 0);
+  s5p_sort(a, n);
   uns i = 0;
   while (i < n)
     {
   uns i = 0;
   while (i < n)
     {
@@ -513,6 +520,8 @@ test_graph(uns mode, u64 size)
   uns N = 3;
   while ((u64)N*(N+2)*4 < size)
     N = nextprime(N);
   uns N = 3;
   while ((u64)N*(N+2)*4 < size)
     N = nextprime(N);
+  if (!size)
+    N = 0;
   msg(L_INFO, ">>> Graph%s (N=%u)", (mode ? "" : " with custom presorting"), N);
   s5_N = N;
   s5_K = N/4*3;
   msg(L_INFO, ">>> Graph%s (N=%u)", (mode ? "" : " with custom presorting"), N);
   s5_N = N;
   s5_K = N/4*3;
@@ -663,9 +672,20 @@ main(int argc, char **argv)
          goto usage;
        break;
       case 't':
          goto usage;
        break;
       case 't':
-       t = atol(optarg);
-       if (t >= TMAX)
-         goto usage;
+         {
+           char *w[32];
+           int f = sepsplit(optarg, ',', w, ARRAY_SIZE(w));
+           if (f < 0)
+             goto usage;
+           t = 0;
+           for (int i=0; i<f; i++)
+             {
+               int j = atol(w[i]);
+               if (j >= TMAX)
+                 goto usage;
+               t |= 1 << j;
+             }
+         }
        break;
       case 'v':
        sorter_trace++;
        break;
       case 'v':
        sorter_trace++;
@@ -678,10 +698,8 @@ main(int argc, char **argv)
   if (optind != argc)
     goto usage;
 
   if (optind != argc)
     goto usage;
 
-  if (t != ~0U)
-    run_test(t, size);
-  else
-    for (uns i=0; i<TMAX; i++)
+  for (uns i=0; i<TMAX; i++)
+    if (t & (1 << i))
       run_test(i, size);
 
   return 0;
       run_test(i, size);
 
   return 0;