Example usage for com.google.gwt.coreext.client JsIntegerDoubleMap create

List of usage examples for com.google.gwt.coreext.client JsIntegerDoubleMap create

Introduction

In this page you can find the example usage for com.google.gwt.coreext.client JsIntegerDoubleMap create.

Prototype

public static JsIntegerDoubleMap create() 

Source Link

Document

Create a new empty map.

Usage

From source file:com.google.speedtracer.client.visualizations.model.ReportDataCollector.java

License:Apache License

private ReportData gatherDataWithinWindowImpl(double leftBound, double rightBound,
        List<? extends EventRecord> eventList, Collector collector) {
    // Find the index of the last record that falls within the right edge of the
    // selected window bound.
    int numRecords = eventList.size();
    int index = EventRecord.getIndexOfRecord(eventList, rightBound);

    // If we have a bogus insertion index, do nothing.
    if (index <= 0 || index > numRecords) {
        return new ReportData(null, null);
    }/*  w w  w . j  av a2 s  . co  m*/

    // The insertion index is always to the right of the record we want to start
    // with. Unless we hit it directly. But if we hit the start time directly
    // with the right edge of the window, we can ignore anyways. So it is always
    // correct to decrement index by 1.
    index = index - 1;

    // Not all records will be UiEvents. But we want access to fields like
    // duration and the type maps. These will return appropriate 0 and null
    // values for non-UiEvent EventRecords.
    UiEvent record = eventList.get(index).cast();
    final List<HintRecord> hints = new ArrayList<HintRecord>();
    final JsIntegerDoubleMap aggregateTypeDurations = JsIntegerDoubleMap.create();

    // We want to add a wedge in the pie chart for the time the browser's UI
    // thread was available.
    collector.setTotalAvailableTime(rightBound - leftBound);

    // We are starting at the right edge of the window, which may chop an event.
    if (UiEvent.isUiEvent(record)) {
        record = splitEventTreeOnBoundary(record, rightBound, true);
        // Guard against having the record split an event outside the window.
        if (record == null) {
            return new ReportData(null, null);
        }
    }

    // We will walk backward to find the left window boundary. Because we can
    // have ResourceUpdate records that have nonsensical time stamps, we place
    // the terminating condition within the loop.
    while (index >= 0) {
        double endTime = record.getTime() + record.getDuration();
        // Our real terminating condition is if the record passes the left edge.
        if (endTime < leftBound) {
            break;
        }
        // Chop records that fall within the window, but start to the left of
        // the leftBound.
        if (UiEvent.isUiEvent(record) && record.getTime() < leftBound && endTime >= leftBound) {
            record = splitEventTreeOnBoundary(record, leftBound, false);
            assert (record != null) : "Splitting a node should yield a valid non-null clone here!";
        }

        collector.examineRecord(record, aggregateTypeDurations);

        // Walk backward.
        --index;
        if (index >= 0) {
            record = eventList.get(index).cast();
        }
    }

    collector.finishCollection(aggregateTypeDurations, hints);

    return new ReportData(aggregateTypeDurations, hints);
}

From source file:com.google.speedtracer.client.visualizations.view.EventTraceBreakdown.java

License:Apache License

private void ensureMasterIsRendered() {
    if (masterCanvasElement != null) {
        return;/*ww w.  j  a  v  a 2 s.co  m*/
    }

    // See comment in renderNode.
    final JsIntegerDoubleMap accumlatedErrorByType = JsIntegerDoubleMap.create();
    final Canvas canvas = new Canvas(MASTER_COORD_WIDTH, COORD_HEIGHT);
    traverseAndRender(canvas, null, rootEvent, accumlatedErrorByType);
    masterCanvasElement = canvas.getElement();
}