00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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( 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( 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 }