comparison tools/fanalyze.c @ 2274:a4c1fafd442a

Add a progress indicator when "slow" matching is expected.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 17 Jun 2019 12:54:33 +0300
parents 6878aad714ce
children 519c8726b235
comparison
equal deleted inserted replaced
2273:6878aad714ce 2274:a4c1fafd442a
926 if (setMode == FA_MATCHES) 926 if (setMode == FA_MATCHES)
927 { 927 {
928 // 928 //
929 // Attempt to find matching sequences of N+ 929 // Attempt to find matching sequences of N+
930 // 930 //
931 dmPrint(0, "Attempting to find matching sequences of %" DM_PRIu_SIZE_T" bytes or more\n", 931 BOOL slow = FALSE;
932 int ss = 0;
933 dmPrint(0, "Attempting to find matching sequences of %" DM_PRIu_SIZE_T" bytes or more.\n",
932 optMinMatchLen); 934 optMinMatchLen);
933 935
934 if (totalSize > 32*1024) 936 if (totalSize > 32*1024)
935 { 937 {
936 dmPrint(0, 938 dmPrint(0,
937 "WARNING! Total data size is large, and the matching \"algorithm\"\n" 939 "WARNING! Total data size is large, and the matching \"algorithm\"\n"
938 "used is horribly inefficient. This will be quite slow ...\n"); 940 "used is horribly inefficient. This will be quite slow ...\n");
941 slow = TRUE;
939 } 942 }
940 943
941 for (int nfile1 = 0; nfile1 < nsrcFiles; nfile1++) 944 for (int nfile1 = 0; nfile1 < nsrcFiles; nfile1++)
942 { 945 {
943 DMSourceFile *file1 = &srcFiles[nfile1]; 946 DMSourceFile *file1 = &srcFiles[nfile1];
945 for (int nfile2 = 0; nfile2 < nsrcFiles; nfile2++) 948 for (int nfile2 = 0; nfile2 < nsrcFiles; nfile2++)
946 if (nfile2 != nfile1 && !file1->analyzed) 949 if (nfile2 != nfile1 && !file1->analyzed)
947 { 950 {
948 DMSourceFile *file2 = &srcFiles[nfile2]; 951 DMSourceFile *file2 = &srcFiles[nfile2];
949 952
953 if (slow)
954 {
955 dmPrint(0,
956 "Processing .. %1.1f%%\r",
957 (float) ss * 100.0f / (float) (nsrcFiles * (nsrcFiles - 1)));
958 ss++;
959 }
950 // Find longest possible matching sequence in file2, if any 960 // Find longest possible matching sequence in file2, if any
951 for (size_t moffs1 = 0; moffs1 + optMinMatchLen < file1->size;) 961 for (size_t moffs1 = 0; moffs1 + optMinMatchLen < file1->size;)
952 { 962 {
953 size_t cnt = 0; 963 size_t cnt = 0;
954 for (size_t moffs2 = 0; moffs2 + optMinMatchLen < file2->size; moffs2++) 964 for (size_t moffs2 = 0; moffs2 + optMinMatchLen < file2->size; moffs2++)
978 file1->analyzed = TRUE; 988 file1->analyzed = TRUE;
979 } 989 }
980 990
981 done: 991 done:
982 992
993 if (slow)
994 dmPrint(0, "\n\n");
995
983 for (int nmatch = 0; nmatch < ndmSequences; nmatch++) 996 for (int nmatch = 0; nmatch < ndmSequences; nmatch++)
984 { 997 {
985 DMMatchSeq *seq = &dmSequences[nmatch]; 998 DMMatchSeq *seq = &dmSequences[nmatch];
986 999
987 qsort(&seq->places, seq->nplaces, sizeof(DMMatchPlace), 1000 qsort(&seq->places, seq->nplaces, sizeof(DMMatchPlace),