001 package jp.osdl.jbento2.analyzer;
002
003 import java.text.DecimalFormat;
004
005
006 public class SummaryBuilder {
007
008 private SampleList allSamples;
009 private SampleList samples;
010 private DecimalFormat format = new DecimalFormat("#0.00");
011
012 public SummaryBuilder(SampleList allSamples, SampleList samples) {
013 this.allSamples = allSamples;
014 this.samples = samples;
015 }
016
017 public String build() {
018 TextTable tt = new TextTable(6, TextTable.ALIGN_RIGHT, ",");
019 tt.setAlign(0, TextTable.ALIGN_LEFT);
020 tt.addRow(new String[] {
021 "", "time[msec]", "time[sec]", "time[min]", "start", "end"
022 });
023 tt.addSeparator("-");
024 buildRow("All", allSamples, tt);
025 buildRow("InRange", samples, tt);
026 return tt.toString();
027 }
028
029 private void buildRow(String label, SampleList samples, TextTable tt) {
030 long start =
031 SampleUtils.getMinStartTime(samples).getMillitime();
032 long end =
033 SampleUtils.getMaxEndTime(samples).getMillitime();
034 tt.addRow(new String[] {
035 label,
036 String.valueOf(end - start),
037 format.format((end - start) / 1000.0),
038 format.format((end - start) / 1000.0 / 60.0),
039 String.valueOf(start),
040 String.valueOf(end)
041 });
042 }
043 }
044