/* Copyright (c) 2004 Dmitri Nikulin, Victoria, Australia, 3150 All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY DMITRI NIKULIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DMITRI NIKULIN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "lep.h" #undef SZ #define SZ 8000003 #define TP2MB(t,l) (t/((l/(1<<21))?:1)) static const char *tests[]={ "ed", "hH", "tt", "rr", "s5s5", "R6R20", "x42x42", "ehtrs5R6x42x42R20s5rtHd" #ifdef DEBUG ,"C", "Z", "E" #endif }; void tdiag(u_long t1,u_long t2,float tp1,float tp2) { printf(" Algorithm appears to have a"); if(t1==t2 && t1==0) { printf(Y" zero runtime (O(0))\n"); }else if((t1==t2)||((t1+(t1/4)>=t2)&&(t1-(t1/4)<=t2))) { printf(Y" constant runtime (O(1))\n"); }else if((tp1==tp2)||((tp1+(tp1/2)>=tp2)&&(tp1-(tp1/2)<=tp2))) { printf(G" linear runtime (O(n))\n"); }else if(tp2>tp1) { printf("n "R"exponential runtime (O(n*n))\n"); }else if(tp2 Testing '%s'...\n",tests[i]); b=realloc(b,l=SZ); memcpy(b,bb,l); printf(" > Integrity: "); MD5_Init(&c); work(tests[i],&b,&l,&k); MD5_Update(&c,b,SZ); MD5_Final(r,&c); if(memcmp(r,h,16)==0) { printf(G"succeeded!\n"W); }else{ printf(R"failed!\n"W); continue; } printf(" > Runtime...\n"); for(j=2;j<4;j++) { b=realloc(b,l=(SZ*(1<