Minor bug fixed to progress meter

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@22 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2009-03-02 22:19:39 +00:00
parent 851e1df072
commit a81a1bdbb4
2 changed files with 10 additions and 4 deletions

View File

@ -102,7 +102,7 @@ public class FileProgressTracker<T> implements Iterator<T> {
} }
public int averageRecordSize() { public int averageRecordSize() {
return Math.round((int)Utils.average(recordSizes(), Math.min(historyI - 1, history.size())) / samplingFrequency); return Math.round((int)Utils.average(recordSizes(), Math.min(historyI - 1, historySize)) / samplingFrequency);
} }
public double processingRate() { public double processingRate() {
@ -110,7 +110,7 @@ public class FileProgressTracker<T> implements Iterator<T> {
} }
public long estRecordsInFile() { public long estRecordsInFile() {
return (long)(getFileSize() / averageRecordSize()); return (long)(getFileSize() / Math.max(averageRecordSize(),1));
} }
public double estFractionProgressThroughFile() { public double estFractionProgressThroughFile() {
@ -128,6 +128,7 @@ public class FileProgressTracker<T> implements Iterator<T> {
public void printStatus() { public void printStatus() {
System.out.printf("FileProgressTracker:%n"); System.out.printf("FileProgressTracker:%n");
System.out.printf(" -> File size is: %d%n", getFileSize()); System.out.printf(" -> File size is: %d%n", getFileSize());
System.out.printf(" -> Sampling depth: %d%n", historyI);
System.out.printf(" -> File position: %d%n", getPosition()); System.out.printf(" -> File position: %d%n", getPosition());
System.out.printf(" -> Number of records processed: %d%n", nRecordsProcessed()); System.out.printf(" -> Number of records processed: %d%n", nRecordsProcessed());
System.out.printf(" -> Average record size is %d%n", averageRecordSize()); System.out.printf(" -> Average record size is %d%n", averageRecordSize());
@ -140,6 +141,7 @@ public class FileProgressTracker<T> implements Iterator<T> {
} }
public String progressMeter() { public String progressMeter() {
//printStatus();
return String.format("Est. %.2f%% completed, time remaining (%.2f hrs / %.2f min) of (%.2f hrs / %.2f min) total", return String.format("Est. %.2f%% completed, time remaining (%.2f hrs / %.2f min) of (%.2f hrs / %.2f min) total",
estFractionProgressThroughFile() * 100.0, estFractionProgressThroughFile() * 100.0,
estTimeTotal() / (60*60), estTimeTotal() / (60), estTimeTotal() / (60*60), estTimeTotal() / (60),
@ -149,7 +151,10 @@ public class FileProgressTracker<T> implements Iterator<T> {
public ArrayList<Long> recordSizes() { public ArrayList<Long> recordSizes() {
ArrayList<Long> sizes = new ArrayList<Long>(history); ArrayList<Long> sizes = new ArrayList<Long>(history);
for ( int i = 0; i < historySize; i++ ) { for ( int i = 0; i < historySize; i++ ) {
sizes.set(i, history.get(historyIndex(i)) - history.get(historyIndex(i-1))); long val = 0;
if ( history.get(historyIndex(i)) >= history.get(historyIndex(i-1) ) )
val = history.get(historyIndex(i)) - history.get(historyIndex(i-1));
sizes.set(i, val);
} }
// for ( long size : sizes ) { // for ( long size : sizes ) {

View File

@ -81,9 +81,10 @@ public class Utils {
break; break;
sum += x; sum += x;
i++; i++;
//System.out.printf(" %d/%d", sum, i);
} }
//System.out.printf("Sum = %d, n = %d, avg = %f%n", sum, i, (1.0 * sum) / i); //System.out.printf("Sum = %d, n = %d, maxI = %d, avg = %f%n", sum, i, maxI, (1.0 * sum) / i);
return (1.0 * sum) / i; return (1.0 * sum) / i;
} }