Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

TestFPPerf.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Fri Jul 16 17:19:13 EDT 2004 by ken@xorian.net  
00020 //      modified on Sat Feb 12 17:36:01 PST 2000 by mann  
00021 //      modified on Fri Dec 12 08:57:40 PST 1997 by heydon
00022 
00023 #include <stdlib.h>
00024 
00025 extern "C" {
00026 #include <sys/time.h>
00027 }
00028 
00029 #if defined (__linux__)
00030 #include <unistd.h>
00031 #endif // __linux
00032 
00033 #include "Basics.H"
00034 #include "FP.H"
00035 
00036 using std::ostream;
00037 using std::cout;
00038 using std::endl;
00039 
00040 ostream& operator << (ostream &os, const RawFP &fp) throw ()
00041 {
00042     char buff[17];
00043     for (int i = 0; i < PolyVal::WordCnt; i++) {
00044         sprintf(buff, "%016" FORMAT_LENGTH_INT_64 "x", fp.w[i]);
00045         os << buff;
00046         if (i < PolyVal::WordCnt - 1) os << " ";
00047     }
00048     return os;
00049 }
00050 
00051 int main(int argc, char *argv[]) 
00052 {
00053     int arg1 = (argc > 1) ? atoi(argv[1]) : 10;
00054     int arg2 = (argc > 2) ? atoi(argv[2]) : 1;
00055     Text longS("a");
00056     int i;
00057     for (i = 0; i < arg1; i++) {
00058         longS += longS;
00059     }
00060     int longSLen = longS.Length();
00061     struct timeval start;
00062     int iterCnt = (1 << arg2);
00063     {
00064         FP::Tag tag(longS.cchars(), longSLen);
00065         RawFP rawTag;
00066         tag.Unpermute(/*OUT*/ rawTag);
00067         cout << "After first iteration: Raw FP::Tag(longS) = " <<rawTag<<endl;
00068     }
00069     FP::Tag tag("");
00070     (void) gettimeofday(&start, NULL);
00071     for (i = 0; i < iterCnt; i++) {
00072         tag.Extend(longS.cchars(), longSLen);
00073     }
00074     struct timeval end;
00075     (void) gettimeofday(&end, NULL);
00076     RawFP rawTag;
00077     tag.Unpermute(/*OUT*/ rawTag);
00078     cout << "After last iteration:  Raw FP::Tag(longS) = " <<rawTag<<endl;
00079     int totalLen = iterCnt * longSLen;
00080     cout << "Done fingerprinting " << totalLen << " bytes" << endl;
00081     int startT = (start.tv_sec * 1000) + (start.tv_usec / 1000);
00082     int endT = (end.tv_sec * 1000) + (end.tv_usec / 1000);
00083     int totalTm = (endT - startT) + 1;
00084     cout << "Elapsed time = " << totalTm << "ms" << endl;
00085     cout << "Fingerprinted " << ((float)totalLen/(float)totalTm)
00086         << " bytes/ms" << endl;
00087     
00088 }

Generated on Mon May 8 00:48:41 2006 for Vesta by  doxygen 1.4.2