Folding@Home Stats currently unavailable


View unanswered posts | View active topics It is currently Sat May 18, 2013 12:10 pm









Reply to topic  [ 1 post ] 
 ft.c 
Author Message
User avatar

Joined: Mon Jan 01, 2007 12:21 am
Posts: 919
Location: Salt Lake City
Post ft.c
/*
* frametimes.c Read FAHlog.txt and calculate frame times
*
* ~$cc frametimes.c; ./a.out; ./a.out -v; cp a.out frametimes
* Runs in ~/Library/Folding@home as ~$./frametimes
* (I do ~$sudo cp wutime /usr/local/bin/ft)
* Requires FAHlog.txt to be present, can read FAHlog-Prev.txt with -p.
* Looong output with -v, over 760 lines for me now.
* (I do ~$./frametimes -v | wc -l [to see its size])
* (and ~$./frametimes -v | grep Error [to see the bad times])
*
* stevew Folding@home Forum mar-4-2010
* Team Hack-a-Day 44851
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NULLP (char *)NULL
#define NULLFP (FILE *)NULL

void
usage()
{
printf("There are two flags: -v and -p\n");
printf(" -v prints all individual frame times.\n");
printf(" -p uses FAHlog-Prev.txt instead of FAHlog.txt\n");
printf(" flags need to be separate -p -v, not -pv\n");
printf("\n floor and ceiling times are +/- 30%% average of 1st pass\n");

}

float
hms2fsec(buf)
char *buf;
{
float dtime;

/* [hh:mm:ss] into seconds */
dtime = atof(&buf[1]) * 3600 + atof(&buf[4]) * 60 + atof(&buf[7]);

return (dtime);
}

int
main(int argc, char *argv[])
{
char *p, buf[128], *FileName = "FAHlog.txt\0";;
float prevtime, dtime, sum, count, temp;
float floor = 14.4; /* 24 hour completion */
float ceiling = 86.0; /* 6 day time limit */
FILE *fp;
int i, PASS, total_lines, trash_lines = 0;
int PRINTframe = 0, bad_time = 0;
int TWOpasses = 1;

prevtime = dtime = sum = count = temp = 0.0;

i = 1;
while (--argc) {
/* is flag? */
if (*(p = argv[i]) == '-' && p[1] == 'v') {
PRINTframe = 1;
++i;
continue;
}
if (*(p = argv[i]) == '-' && p[1] == 'p') {
FileName = "FAHlog-Prev.txt\0";
++i;
continue;
}
usage();
return (0);
}

printf("Reading %s\n", FileName);
if ((fp = fopen(FileName, "r")) == NULLFP) {
printf("Could not open %s\n", FileName);
return (-1);
}
for (PASS = 1; PASS <= 2; ++PASS) {
while (fgets(buf, 128, fp) != NULLP) {
++total_lines;
if (strstr(buf, "(0%)\0") != NULLP) {
printf("Here's where totals should print.\n");
prevtime = hms2fsec(buf);
}
if (strstr(buf, "out of\0") != NULLP) {
dtime = hms2fsec(buf);
/* test for negative, true? add 24:00 hours */
if ((dtime - prevtime) / 60 < 0)
temp = (dtime - prevtime + 86400) / 60;
else
temp = (dtime - prevtime) / 60;
if (temp > floor && temp < ceiling) {
if (PRINTframe && PASS == 2)
printf("frame time %4.2f\n", temp);
sum += temp;
count++;
prevtime = dtime;
} else if (PRINTframe && PASS == 2) {
printf("Error bad frame time %4.2f\n", temp);
++bad_time;
}
prevtime = dtime;
} else {
++trash_lines;
}
}
/* +/- 10% bounding */
floor = 0.7 * (sum / count);
ceiling = 1.3 * (sum / count);
if (PASS == 1) {
trash_lines = total_lines = bad_time = 0;
sum = count = 0.0;
rewind(fp);
}
} /* end PASS */
printf("Average frame time: %4.2f, ", (sum / count));
printf("Frames counted = %3.0f\n", count);
if (PRINTframe) {
printf("total lines read = %d, bad time = %d, trash lines = %d\n",
total_lines, bad_time, trash_lines);
}
printf("------------------------------\n");
return (0);
}


Mon Mar 28, 2011 2:57 pm
Profile


Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.