/*
* Copyright (c) 2000-2001, 2004 Proofpoint, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*/
SM_RCSID("@(#)$Id: b-strcmp.c,v 1.15 2013-11-22 20:51:42 ca Exp $")
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void
char *str;
{
exit(1);
}
void
purpose()
{
printf("This program benchmarks the performance differences between\n");
printf("strcasecmp() and sm_strcasecmp().\n");
printf("These tests may take several minutes to complete.\n");
}
int
int argc;
char *argv[];
{
long a;
int k;
bool doit = false;
long loops;
long j;
{
switch ((char) k)
{
case 'd':
doit = true;
break;
default:
break;
}
}
if (!doit)
{
purpose();
printf("If you want to run it, specify -d as option.\n");
return 0;
}
/* Run-time comments to the user */
purpose();
printf("\n");
for (k = 0; k < 3; k++)
{
switch (k)
{
case 0:
break;
case 1:
break;
case 2:
break;
}
printf("Test %d: strcasecmp(%s, %s) versus sm_strcasecmp()\n",
for (;;)
{
j = 0;
fatal("gettimeofday");
for (a = 0; a < loops; a++)
fatal("gettimeofday");
printf("\tstrcasecmp() result: %ld seconds [%ld]\n",
one, j);
j = 0;
fatal("gettimeofday");
for (a = 0; a < loops; a++)
fatal("gettimeofday");
printf("\tsm_strcasecmp() result: %ld seconds [%ld]\n",
two, j);
break;
{
printf("\t\t** results too close: no decision\n");
break;
}
else
{
printf("\t\t** results too close redoing test %ld times **\n",
loops);
}
}
}
printf("\n\n");
printf("Interpreting the results:\n");
printf("\tFor differences larger than 2 seconds, the lower value is\n");
printf("\tbetter and that function should be used for performance\n");
printf("\treasons.\n\n");
printf("This program will re-run the tests when the difference is\n");
printf("less than 2 seconds.\n");
printf("The result will vary depending on the compiler optimization\n"); printf("level used. Compiling the sendmail libsm library with a\n");
printf("better optimization level can change the results.\n");
return 0;
}