cppcheck/tools/times.c

48 lines
1.1 KiB
C
Raw Normal View History

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
2012-12-11 10:43:38 +01:00
char *replace(char *str, char before, char after)
{
2012-11-27 12:20:23 +01:00
while (strchr(str,before))
*strchr(str,before) = after;
return str;
}
2012-12-11 10:43:38 +01:00
int main()
{
FILE *f = fopen("times.log", "rt");
if (!f)
return 1;
char lines[64][64] = {0};
int n = 0;
float mintime=0.0f, maxtime=0.0f;
char rev[10] = {0};
char line[128] = {0};
while (fgets(line,sizeof(line),f) && n < 64) {
2012-11-27 12:20:23 +01:00
replace(line,'\r','\0');
replace(line,'\n','\0');
if (strncmp(line,"HEAD is now at ", 15) == 0) {
if (rev[0])
2012-11-27 12:20:23 +01:00
sprintf(lines[n++],"%s\t%.1f\t%.1f", rev, mintime, maxtime);
strncpy(rev, line+15, 7);
mintime = 0.0f;
maxtime = 0.0f;
}
if (strncmp(line,"Overall time:",13)==0) {
float time = atof(line+14);
if (mintime < 0.1f || time < mintime)
mintime = time;
2012-11-27 12:20:23 +01:00
if (time > maxtime)
maxtime = time;
}
}
while (n > 0)
printf("%s\n", lines[--n]);
return 0;
}