FileDocCategorySizeDatePackage
DisplaySyncPerf.javaAPI DocAndroid 1.5 API8453Wed May 06 22:41:08 BST 2009com.android.ddmuilib.log.event

DisplaySyncPerf

public class DisplaySyncPerf extends SyncCommon

Fields Summary
org.jfree.chart.labels.CustomXYToolTipGenerator
mTooltipGenerator
List[]
mTooltips
private static final int
DB_QUERY
private static final int
DB_WRITE
private static final int
HTTP_NETWORK
private static final int
HTTP_PROCESSING
private static final int
NUM_SERIES
private static final String[]
SERIES_NAMES
private static final Color[]
SERIES_COLORS
private static final double[]
SERIES_YCOORD
private static final int
EVENT_DB_OPERATION
private static final int
EVENT_HTTP_STATS
final int
EVENT_DB_QUERY
final int
EVENT_DB_WRITE
private org.jfree.data.time.TimePeriodValues[]
mDatasets
Constructors Summary
public DisplaySyncPerf(String name)
Constructs a graph of network and database stats.

param
name The name of this graph in the graph list.

        super(name);
    
Methods Summary
public org.eclipse.swt.widgets.ControlcreateComposite(org.eclipse.swt.widgets.Composite parent, com.android.ddmlib.log.EventLogParser logParser, ILogColumnListener listener)
Creates the UI for the event display.

param
parent the parent composite.
param
logParser the current log parser.
return
the created control (which may have children).

        Control composite = createCompositeChart(parent, logParser, "Sync Performance");
        resetUI();
        return composite;
    
intgetDisplayType()
Gets display type

return
display type as an integer

        return DISPLAY_TYPE_SYNC_PERF;
    
voidnewEvent(com.android.ddmlib.log.EventContainer event, com.android.ddmlib.log.EventLogParser logParser)
Updates the display with a new event.

param
event The event
param
logParser The parser providing the event.

        super.newEvent(event, logParser); // Handle sync operation
        try {
            if (event.mTag == EVENT_DB_OPERATION) {
                // 52000 db_operation (name|3),(op_type|1|5),(time|2|3)
                String tip = event.getValueAsString(0);
                long endTime = (long) event.sec * 1000L + (event.nsec / 1000000L);
                int opType = Integer.parseInt(event.getValueAsString(1));
                long duration = Long.parseLong(event.getValueAsString(2));

                if (opType == EVENT_DB_QUERY) {
                    mDatasets[DB_QUERY].add(new SimpleTimePeriod(endTime - duration, endTime),
                            SERIES_YCOORD[DB_QUERY]);
                    mTooltips[DB_QUERY].add(tip);
                } else if (opType == EVENT_DB_WRITE) {
                    mDatasets[DB_WRITE].add(new SimpleTimePeriod(endTime - duration, endTime),
                            SERIES_YCOORD[DB_WRITE]);
                    mTooltips[DB_WRITE].add(tip);
                }
            } else if (event.mTag == EVENT_HTTP_STATS) {
                // 52001 http_stats (useragent|3),(response|2|3),(processing|2|3),(tx|1|2),(rx|1|2)
                String tip = event.getValueAsString(0) + ", tx:" + event.getValueAsString(3) +
                        ", rx: " + event.getValueAsString(4);
                long endTime = (long) event.sec * 1000L + (event.nsec / 1000000L);
                long netEndTime = endTime - Long.parseLong(event.getValueAsString(2));
                long netStartTime = netEndTime - Long.parseLong(event.getValueAsString(1));
                mDatasets[HTTP_NETWORK].add(new SimpleTimePeriod(netStartTime, netEndTime),
                        SERIES_YCOORD[HTTP_NETWORK]);
                mDatasets[HTTP_PROCESSING].add(new SimpleTimePeriod(netEndTime, endTime),
                        SERIES_YCOORD[HTTP_PROCESSING]);
                mTooltips[HTTP_NETWORK].add(tip);
                mTooltips[HTTP_PROCESSING].add(tip);
            }
        } catch (InvalidTypeException e) {
        }
    
voidprocessSyncEvent(com.android.ddmlib.log.EventContainer event, int auth, long startTime, long stopTime, java.lang.String details, boolean newEvent, int syncSource)
Callback from super.newEvent to process a sync event.

param
event The sync event
param
startTime Start time (ms) of events
param
stopTime Stop time (ms) of events
param
details Details associated with the event.
param
newEvent True if this event is a new sync event. False if this event
param
syncSource

        if (newEvent) {
            mDatasets[auth].add(new SimpleTimePeriod(startTime, stopTime), SERIES_YCOORD[auth]);
        }
    
voidresetUI()
Resets the display.

        super.resetUI();
        XYPlot xyPlot = mChart.getXYPlot();
        xyPlot.getRangeAxis().setVisible(false);
        mTooltipGenerator = new CustomXYToolTipGenerator();
        mTooltips = new List[NUM_SERIES];

        XYBarRenderer br = new XYBarRenderer();
        br.setUseYInterval(true);
        mDatasets = new TimePeriodValues[NUM_SERIES];

        TimePeriodValuesCollection tpvc = new YIntervalTimePeriodValuesCollection(1);
        xyPlot.setDataset(tpvc);
        xyPlot.setRenderer(br);

        for (int i = 0; i < NUM_SERIES; i++) {
            br.setSeriesPaint(i, SERIES_COLORS[i]);
            mDatasets[i] = new TimePeriodValues(SERIES_NAMES[i]);
            tpvc.addSeries(mDatasets[i]);
            mTooltips[i] = new ArrayList<String>();
            mTooltipGenerator.addToolTipSeries(mTooltips[i]);
            br.setSeriesToolTipGenerator(i, mTooltipGenerator);
        }