| 1 | package bin; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.Collections; |
| 5 | |
| 6 | import fileIO.ByteStreamWriter; |
| 7 | import shared.Tools; |
| 8 | |
| 9 | public class ChartMaker { |
| 10 | |
| 11 | static void makeChartFromBins(String fname, ArrayList<Bin> list) { |
| 12 | Collections.sort(list, new BinComparator()); |
| 13 | ByteStreamWriter bsw=new ByteStreamWriter(fname, true, false, false); |
| 14 | bsw.start(); |
| 15 | bsw.print("#Bin\tSize\tClean\tDirty\n"); |
| 16 | double size=0, clean=0, dirty=0; |
| 17 | int i=0; |
| 18 | for(Bin b : list) { |
| 19 | double contam=b.size()*Tools.max(0, b.contam); |
| 20 | size+=b.size(); |
| 21 | clean+=(b.size()-contam); |
| 22 | dirty+=contam; |
| 23 | bsw.print(i).tab().print((long)size).tab().print((long)clean).tab().print((long)dirty).println(); |
| 24 | i++; |
| 25 | } |
| 26 | bsw.poisonAndWait(); |
| 27 | } |
| 28 | |
| 29 | static void makeChartFromBinStats(String fname, ArrayList<BinStats> list) { |
| 30 | Collections.sort(list, new BinStatsComparator()); |
| 31 | ByteStreamWriter bsw=new ByteStreamWriter(fname, true, false, false); |
| 32 | bsw.start(); |
| 33 | bsw.print("#Bin\tSize\tClean\tDirty\n"); |
| 34 | double size=0, clean=0, dirty=0; |
| 35 | int i=0; |
| 36 | for(BinStats b : list) { |
| 37 | double contam=b.size*Tools.max(0, b.contam); |
| 38 | size+=b.size; |
| 39 | clean+=(b.size-contam); |
| 40 | dirty+=contam; |
| 41 | bsw.print(i).tab().print((long)size).tab().print((long)clean).tab().print((long)dirty).println(); |
| 42 | i++; |
| 43 | } |
| 44 | bsw.poisonAndWait(); |
| 45 | } |
| 46 | |
| 47 | } |