X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/e2edda6866f01a1a9051abedc91c6d5a9d6aa2d8..c97fbcf9622edc35b594bf574f553f7f13c21164:/perftest.c diff --git a/perftest.c b/perftest.c index 4b8d158..d356ce9 100644 --- a/perftest.c +++ b/perftest.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: perftest.c,v 1.1 2004/04/21 00:37:32 mdw Exp $ + * $Id$ * * Measure performance of various operations (Unix-specific) * * (c) 2004 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,12 +15,12 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -63,9 +63,12 @@ #include "ec.h" #include "group.h" +#include "cc.h" #include "gcipher.h" #include "ghash.h" #include "gmac.h" +#include "ectab.h" +#include "ptab.h" /*----- Options -----------------------------------------------------------*/ @@ -426,14 +429,14 @@ static void hash_run(void *cc) /* --- Job table --- */ -typedef struct jobobs { +typedef struct jobops { const char *name; void *(*init)(opts *); void (*run)(void *); } jobops; static const jobops jobtab[] = { - { "g-prime-exp", grp_init, gr_run }, + { "g-prime-exp", grp_init, gr_run }, { "g-ec-mul", grec_init, gr_run }, { "g-prime-exp-sim", grp_init, grsim_run }, { "g-ec-mul-sim", grec_init, grsim_run }, @@ -452,7 +455,7 @@ static const jobops jobtab[] = { /*----- Main code ---------------------------------------------------------*/ -static void version(FILE *fp) +void version(FILE *fp) { pquis(fp, "$, Catacomb " VERSION "\n"); } @@ -469,9 +472,40 @@ static void help(FILE *fp) usage(fp); pquis(fp, "\n\ Various performance tests.\n\ +\n\ +Options:\n\ +\n\ +-h, --help Show this help text.\n\ +-v, --version Show program version number.\n\ +-u, --usage Show terse usage message.\n\ +-l, --list [ITEM...] List all the various names of things.\n\ +\n\ +-C, --name=NAME Select curve/DH-group/enc/hash name.\n\ +-b, --field-bits Field size for g-prime and rsa.\n\ +-B, --group-bits Group size for g-prime; key size for ksched;\n\ + data size for enc and hash.\n\ +-n, --factors=COUNT Number of factors for {exp,mul}-sim.\n\ +-i, --intervals=COUNT Number of intervals to run for. [0; forever]\n\ +-t, --time=TIME Length of an interval in seconds. [1]\n\ "); } +#define LISTS(LI) \ + LI("Lists", list, \ + listtab[i].name, listtab[i].name) \ + LI("Jobs", job, \ + jobtab[i].name, jobtab[i].name) \ + LI("Elliptic curves", ec, \ + ectab[i].name, ectab[i].name) \ + LI("Diffie-Hellman groups", dh, \ + ptab[i].name, ptab[i].name) \ + LI("Encryption algorithms", cipher, \ + gciphertab[i], gciphertab[i]->name) \ + LI("Hash functions", hash, \ + ghashtab[i], ghashtab[i]->name) + +MAKELISTTAB(listtab, LISTS) + static unsigned uarg(const char *what, const char *p) { char *q; @@ -514,6 +548,7 @@ int main(int argc, char *argv[]) { "help", 0, 0, 'h' }, { "version", 0, 0, 'v' }, { "usage", 0, 0, 'u' }, + { "list", 0, 0, 'l' }, { "name", OPTF_ARGREQ, 0, 'C' }, { "field-bits", OPTF_ARGREQ, 0, 'b' }, { "group-bits", OPTF_ARGREQ, 0, 'B' }, @@ -523,12 +558,13 @@ int main(int argc, char *argv[]) { 0, 0, 0, 0 } }; - i = mdwopt(argc, argv, "hvuC:b:B:n:i:t:", opts, 0, 0, 0); + i = mdwopt(argc, argv, "hvulC:b:B:n:i:t:", opts, 0, 0, 0); if (i < 0) break; switch (i) { case 'h': help(stdout); exit(0); case 'v': version(stdout); exit(0); case 'u': usage(stdout); exit(0); + case 'l': exit(displaylists(listtab, argv + optind)); case 'C': o.name = optarg; break; case 'b': o.fbits = uarg("field bits", optarg); break; case 'B': o.gbits = uarg("subgroup bits", optarg); break; @@ -546,7 +582,7 @@ int main(int argc, char *argv[]) p = j->init(&o); n = 0; - ttot = itot = 0; + ttot = itot = 0; gettimeofday(&tv_now, 0); do { tv_addl(&tv_next, &tv_now, o.t, fmod(o.t * MILLION, MILLION));