5 // Functions that provide visible feedback to the user
\r
6 // that progress is being made.
\r
8 static unsigned g_uIter = 0; // Main MUSCLE iteration 1, 2..
\r
9 static unsigned g_uLocalMaxIters = 0; // Max iters
\r
10 static FILE *g_fProgress = stderr; // Default to standard error
\r
11 static char g_strFileName[32]; // File name
\r
12 static time_t g_tLocalStart; // Start time
\r
13 static char g_strDesc[32]; // Description
\r
14 static bool g_bWipeDesc = false;
\r
15 static int g_nPrevDescLength;
\r
16 static unsigned g_uTotalSteps;
\r
18 const char *ElapsedTimeAsStr()
\r
20 time_t Now = time(0);
\r
21 unsigned long ElapsedSecs = (unsigned long) (Now - g_tLocalStart);
\r
22 return SecsToStr(ElapsedSecs);
\r
25 const char *MemToStr(double MB)
\r
30 static char Str[16];
\r
31 static double MaxMB = 0;
\r
32 static double RAMMB = 0;
\r
35 RAMMB = GetRAMSizeMB();
\r
39 double Pct = (MaxMB*100.0)/RAMMB;
\r
42 sprintf(Str, "%.0f MB(%.0f%%)", MaxMB, Pct);
\r
46 void SetInputFileName(const char *pstrFileName)
\r
48 NameFromPath(pstrFileName, g_strFileName, sizeof(g_strFileName));
\r
51 void SetSeqStats(unsigned uSeqCount, unsigned uMaxL, unsigned uAvgL)
\r
56 fprintf(g_fProgress, "%s %u seqs, max length %u, avg length %u\n",
\r
57 g_strFileName, uSeqCount, uMaxL, uAvgL);
\r
59 Log("%u seqs, max length %u, avg length %u\n",
\r
60 uSeqCount, uMaxL, uAvgL);
\r
65 time(&g_tLocalStart);
\r
68 unsigned long GetStartTime()
\r
70 return (unsigned long) g_tLocalStart;
\r
73 void SetIter(unsigned uIter)
\r
83 void SetMaxIters(unsigned uMaxIters)
\r
85 g_uLocalMaxIters = uMaxIters;
\r
88 void SetProgressDesc(const char szDesc[])
\r
90 strncpy(g_strDesc, szDesc, sizeof(g_strDesc));
\r
91 g_strDesc[sizeof(g_strDesc) - 1] = 0;
\r
94 static void Wipe(int n)
\r
96 for (int i = 0; i < n; ++i)
\r
97 fprintf(g_fProgress, " ");
\r
100 void Progress(const char *szFormat, ...)
\r
107 double MB = GetMemUseMB();
\r
111 va_start(ArgList, szFormat);
\r
112 vsprintf(szStr, szFormat, ArgList);
\r
114 fprintf(g_fProgress, "%8.8s %12s %s",
\r
115 ElapsedTimeAsStr(),
\r
119 fprintf(g_fProgress, "\n");
\r
120 fflush(g_fProgress);
\r
123 void Progress(unsigned uStep, unsigned uTotalSteps)
\r
130 double dPct = ((uStep + 1)*100.0)/uTotalSteps;
\r
131 double MB = GetMemUseMB();
\r
132 fprintf(g_fProgress, "%8.8s %12s Iter %3u %6.2f%% %s",
\r
133 ElapsedTimeAsStr(),
\r
141 int n = g_nPrevDescLength - (int) strlen(g_strDesc);
\r
143 g_bWipeDesc = false;
\r
146 fprintf(g_fProgress, "\r");
\r
148 g_uTotalSteps = uTotalSteps;
\r
151 void ProgressStepsDone()
\r
157 double MB = GetMemUseMB();
\r
158 Log("Elapsed time %8.8s Peak memory use %12s Iteration %3u %s\n",
\r
159 ElapsedTimeAsStr(),
\r
168 Progress(g_uTotalSteps - 1, g_uTotalSteps);
\r
169 fprintf(g_fProgress, "\n");
\r
170 g_bWipeDesc = true;
\r
171 g_nPrevDescLength = (int) strlen(g_strDesc);
\r