perftest: Optionally disable group checking.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 26 Dec 2008 12:41:59 +0000 (12:41 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 26 Dec 2008 12:41:59 +0000 (12:41 +0000)
This takes ages on big prime groups, and is almost useless.  It may be
worth making not-checking be the default.

perftest.c

index d356ce9..fff982e 100644 (file)
@@ -79,6 +79,8 @@ typedef struct opts {
   unsigned n;                          /* Number of factors */
   unsigned i;                          /* Number of intervals (or zero) */
   double t;                            /* Time for each interval (secs) */
+  unsigned f;                          /* Flags */
+#define OF_NOCHECK 1u                  /*   Don't do group checking */
 } opts;
 
 /*----- Job switch --------------------------------------------------------*/
@@ -206,7 +208,7 @@ static void *grp_init(opts *o)
     dh_gen(&gp, o->gbits, o->fbits, 0, &rand_global, pgen_evspin, 0);
   }
   c->g = group_prime(&gp);
-  if ((e = G_CHECK(c->g, &rand_global)) != 0)
+  if (!(o->f & OF_NOCHECK) && (e = G_CHECK(c->g, &rand_global)) != 0)
     die(1, "bad group: %s", e);
   if (!o->n) o->n = 1;
   c->n = o->n;
@@ -234,7 +236,7 @@ static void *grec_init(opts *o)
   if ((e = ec_getinfo(&ei, o->name)) != 0)
     die(1, "bad curve: %s", e);
   c->g = group_ec(&ei);
-  if ((e = G_CHECK(c->g, &rand_global)) != 0)
+  if (!(o->f & OF_NOCHECK) && (e = G_CHECK(c->g, &rand_global)) != 0)
     die(1, "bad group: %s", e);
   if (!o->n) o->n = 1;
   c->n = o->n;
@@ -555,10 +557,11 @@ int main(int argc, char *argv[])
       { "factors",     OPTF_ARGREQ,    0,      'n' },
       { "intervals",   OPTF_ARGREQ,    0,      'i' },
       { "time",                OPTF_ARGREQ,    0,      't' },
+      { "no-check",    0,              0,      'q' },
       { 0,             0,              0,      0 }
     };
 
-    i = mdwopt(argc, argv, "hvulC:b:B:n:i:t:", opts, 0, 0, 0);
+    i = mdwopt(argc, argv, "hvulC:b:B:n:i:t:q", opts, 0, 0, 0);
     if (i < 0) break;
     switch (i) {
       case 'h': help(stdout); exit(0);
@@ -571,6 +574,7 @@ int main(int argc, char *argv[])
       case 'n': o.n = uarg("factor count", optarg); break;
       case 'i': o.i = uarg("interval count", optarg); break;
       case 't': o.t = farg("interval length", optarg); break;
+      case 'q': o.f |= OF_NOCHECK; break;
       default: usage(stderr); exit(1);
     }
   }