From d3501eb12247f9ec8c1dface98b76352aee3d2f5 Mon Sep 17 00:00:00 2001 From: "yeongtaik.byeon" Date: Fri, 8 Jun 2012 17:24:17 +0900 Subject: [PATCH] [Title]formatter update & range view data update [Type]update [Module]range view [Priority]normal [CQ#] [Redmine#]5286,5330 [Problem] [Cause] [Solution] [TestCase] --- .../ui/widgets/tables/StatsTable.java | 127 ++++++--------------- .../org/tizen/dynamicanalyzer/utils/Formatter.java | 26 +++++ 2 files changed, 63 insertions(+), 90 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/tables/StatsTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/tables/StatsTable.java index 7a4e71c..9cee520 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/tables/StatsTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/tables/StatsTable.java @@ -81,53 +81,11 @@ public class StatsTable extends DATableComposite { gi.setText(5, max); } - public String computeTimeString(long time) { - long hour = 0; - long minute = 0; - long second = 0; - long msecond = 0; - StringBuffer buf = new StringBuffer(); - - // startTime - hour = time / (60 * 60 * 1000000); - minute = (time - hour * 60 * 60 * 1000000) / (60 * 1000000); - second = (time - hour * 60 * 60 * 1000000 - minute * 60 * 1000000) / 1000000; - msecond = time % 1000000; - - while (msecond > 10 && msecond % 10 == 0) { - msecond /= 10; - } - - if (0 != hour) { - buf.append(hour); - buf.append(":"); - } - if (minute < 10) - buf.append("0"); - buf.append(minute); - - buf.append(":"); - - if (second < 10) - buf.append("0"); - buf.append(second); - if (0 != msecond) { - buf.append("."); - buf.append(msecond); - } - - return buf.toString(); - } - public void insertStartEndTime() { - String start; - String end; - - // startTime - start = computeTimeString(startTime); - end = computeTimeString(endTime); - - insertRangeItem("Time", start, end, null, null, null); + insertRangeItem("Time", + Formatter.toTimeFormat(String.valueOf(startTime)), + Formatter.toTimeFormat(String.valueOf(endTime)), null, null, + null); } private boolean isIncludeRangeSet(int id) { @@ -169,9 +127,11 @@ public class StatsTable extends DATableComposite { break; case TimelineConstants.CHART_TYPE_PROCESS_SIZE: if (xys.getKey().equals(ProcessMemoryChart.SERIES_NAME_VSS)) - ret = "Process-virtual"; + ret = "Process-VSS"; else if (xys.getKey().equals(ProcessMemoryChart.SERIES_NAME_RSS)) - ret = "Process-resident"; + ret = "Process-RSS"; + else if (xys.getKey().equals(ProcessMemoryChart.SERIES_NAME_PSS)) + ret = "Process-PSS"; break; case TimelineConstants.CHART_TYPE_ENERGY: if (xys.getKey().equals(EnergyChart.SERIES_NAME_ENERGY)) @@ -209,14 +169,14 @@ public class StatsTable extends DATableComposite { List xySeries = null; List xyDataItem = null; double xVal; - int min = 0; - int max = 0; - int sum = 0; + double min = 0; + double max = 0; + double sum = 0; double avr = 0; - int count = 0; - int start = 0; - int end = 0; - int val; + double count = 0; + double start = 0; + double end = 0; + double val; int itemID; for (int i = 0; i < pItemName.size(); i++) { @@ -249,7 +209,7 @@ public class StatsTable extends DATableComposite { xVal = (xyDataItem.get(j).getX().doubleValue()); if (j == startIndex) { - val = xyDataItem.get(j).getY().intValue(); + val = xyDataItem.get(j).getY().doubleValue(); min = val; max = val; sum = val; @@ -259,7 +219,7 @@ public class StatsTable extends DATableComposite { } else if (xVal * 1000000 > endTime) break; else { - val = xyDataItem.get(j).getY().intValue(); + val = xyDataItem.get(j).getY().doubleValue(); if (val < min) min = val; @@ -274,46 +234,43 @@ public class StatsTable extends DATableComposite { if (count != 0) avr = (double) sum / (double) count; - DecimalFormat df1 = new DecimalFormat("#,##0.00"); - DecimalFormat df2 = new DecimalFormat("#,##0"); String title = getTitleName(itemID, xys); if (null != title) { switch (itemID) { case TimelineConstants.CHART_TYPE_CPU: insertRangeItem(title, - Formatter.toPercentageFormat((double) start), - Formatter.toPercentageFormat((double) end), + Formatter.toPercentageFormat(start), + Formatter.toPercentageFormat(end), Formatter.toPercentageFormat(avr), - Formatter.toPercentageFormat((double) min), - Formatter.toPercentageFormat((double) max)); + Formatter.toPercentageFormat(min), + Formatter.toPercentageFormat(max)); break; case TimelineConstants.CHART_TYPE_CPU_CORE: insertRangeItem(title, - Formatter.toPercentageFormat((double) start), - Formatter.toPercentageFormat((double) end), + Formatter.toPercentageFormat(start), + Formatter.toPercentageFormat(end), Formatter.toPercentageFormat(avr), - Formatter.toPercentageFormat((double) min), - Formatter.toPercentageFormat((double) max)); + Formatter.toPercentageFormat(min), + Formatter.toPercentageFormat(max)); break; case TimelineConstants.CHART_TYPE_HEAP: insertRangeItem(title, Formatter.toByteFormat(start), Formatter.toByteFormat(end), - Formatter.toByteFormat((int) avr), + Formatter.toByteFormat(avr), Formatter.toByteFormat(min), Formatter.toByteFormat(max)); break; case TimelineConstants.CHART_TYPE_PROCESS_SIZE: - insertRangeItem(title, - Formatter.toByteFormat(start * 1024), - Formatter.toByteFormat(end * 1024), - Formatter.toByteFormat((int) (avr * 1024)), - Formatter.toByteFormat(min * 1024), - Formatter.toByteFormat(max * 1024)); + insertRangeItem(title, Formatter.toByteFormat(start), + Formatter.toByteFormat(end), + Formatter.toByteFormat((avr)), + Formatter.toByteFormat(min), + Formatter.toByteFormat(max)); break; case TimelineConstants.CHART_TYPE_ENERGY: insertRangeItem(title, Formatter.toNumberFormat(start), Formatter.toNumberFormat(end), - Formatter.toNumberFormat((long) avr), + Formatter.toNumberFormat(avr), Formatter.toNumberFormat(min), Formatter.toNumberFormat(max)); break; @@ -330,21 +287,11 @@ public class StatsTable extends DATableComposite { } // File read, write else { - if (endTime - startTime < 1000000) - insertRangeItem(title, null, null, - Formatter.toNumberFormat(sum) + "Bps", - Formatter.toByteFormat(min), - Formatter.toByteFormat(max)); - else - insertRangeItem( - title, - null, - null, - Formatter - .toNumberFormat((long) ((double) sum * (double) (1000000 / (double) (endTime - startTime)))) - + " Bps", - Formatter.toByteFormat(min), - Formatter.toByteFormat(max)); + insertRangeItem(title, null, null, + Formatter.toBpsFormat(sum, startTime, + endTime), + Formatter.toByteFormat(min), + Formatter.toByteFormat(max)); } break; default: diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/Formatter.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/Formatter.java index 7d7d201..0d1ff7d 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/Formatter.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/Formatter.java @@ -1,5 +1,7 @@ package org.tizen.dynamicanalyzer.utils; +import java.text.DecimalFormat; + import org.tizen.dynamicanalyzer.constants.LogCenterConstants; public class Formatter { @@ -188,6 +190,10 @@ public class Formatter { } return output; } + + public static String toNumberFormat(double input){ + return toNumberFormat((long)input); + } public static String toByteFormat(long input) { int reminder = 0; @@ -217,6 +223,26 @@ public class Formatter { } return value; } + public static String toByteFormat(double input) { + return toByteFormat((long)input); + } + + public static String toBpsFormat(long nByte, long startTime, long endTime){ + String value = ""; + DecimalFormat df1 = new DecimalFormat("#,##0.00"); + double Bps = nByte; + + if(endTime - startTime >= 1000000){ + Bps = ((double)nByte * ((double)1000000 / (double)(endTime - startTime))); + } + + value += df1.format(Bps) + " Bps"; + return value; + } + + public static String toBpsFormat(double nByte, long startTime, long endTime){ + return toBpsFormat((long)nByte, startTime, endTime); + } private static String getMeasure(int count) { if (count == 4) { -- 2.7.4