Opened 13 years ago

Last modified 13 years ago

#1140 new Defect

Time Remaining Calculation

Reported by: res1233 Owned by: romw
Priority: Undetermined Milestone: Undetermined
Component: Manager Version: 6.13.1
Keywords: Cc:

Description

The calculation for time remaining is wildy inaccurate. I don't know how it's done in the source, but my method seems to return a much more accurate number as the project progresses. At about 50%, the time remaining number stays fairly steady, and doesn't skip massive numbers of seconds like BOINC currently does. I don't know C very well or I would attempt to send a diff, but I have made an app in AppleScript? that uses the boinccmd command for its data. Here's the script:

set curGraphs to {} --list of paragraphs (lines in bounccmd's output)
set curResults to {} --list of results. Each list member contains CPUTime and fractionDone. Pretty self-explanatory.
set finalResults to {} --list of the final results, after calculation and formatting is done on CPUTime and fractionDone to get the amount of time remaining
set x to do shell script "/usr/bin/boinccmd --get_tasks|grep  active_task_state:\\ 1 -A 8 -B 13"
repeat with i from 1 to 22000
	try
		set curGraphs to curGraphs & {paragraphs (i * 22 - 21) through (i * 22) of x}
	on error errorMessage
		exit repeat
	end try
end repeat
get curGraphs
repeat with selCurGraphs in curGraphs
	repeat with curItem in selCurGraphs
		try
			set projName to do shell script "echo " & quoted form of curItem & "|grep name|grep -v WU"
		end try
		try
			set curCPUTime to do shell script "echo " & quoted form of curItem & "|grep \"current CPU time\""
		end try
		try
			set fracDoneString to do shell script "echo " & quoted form of curItem & "|grep \"fraction done\""
			exit repeat
		end try
	end repeat
	set formattedName to last word of projName
	set CPUTime to last word of curCPUTime
	set fractionDone to last word of fracDoneString
	set curResults to curResults & {{CPUTime, fractionDone, formattedName}}
end repeat
repeat with curResultList in curResults
--Actual calculations start here
	set finalResultsSeconds to ((((1 - (item 2 of curResultList)) / (item 2 of curResultList)) * (item 1 of curResultList)))
	set finalResultsHours to (finalResultsSeconds / 60 / 60) div 1
	set finalResultsMinutes to ((finalResultsSeconds / 60) div 1) - 60 * finalResultsHours
	set finalResultsSeconds to (finalResultsSeconds - 60 * 60 * finalResultsHours - 60 * finalResultsMinutes) div 1
	set finalResults to finalResults & {{item 3 of curResultList, (finalResultsHours & ":" & finalResultsMinutes & ":" & finalResultsSeconds) as string}}
end repeat

Most of this code is parsing of boinccmd's output. The actual calculation starts where I indicate. I know I should comment my code more, but AppleScript?'s syntax has always seemed about as clear as any comments I could write... I hope this is of help. The time remaining currently tells me very little as to when the project will actually finish. Run it and see what happens.

Change History (1)

comment:1 Changed 13 years ago by res1233

To be clear, this is here for the basic syntax so that you can convert it to C. However you guys are getting the current time remaining is clearly wrong, so I hope you can incorporate this into your code.

Note: See TracTickets for help on using tickets.