List of usage examples for com.google.gwt.coreext.client JsIntegerDoubleMap put
public final native void put(int key, double val) ;
From source file:com.google.speedtracer.client.visualizations.model.ReportDataCollector.java
License:Apache License
private static void doAggregation(JsIntegerDoubleMap in, final JsIntegerDoubleMap out) { in.iterate(new IterationCallBack() { public void onIteration(int key, double val) { double duration = out.hasKey(key) ? out.get(key) + val : val; out.put(key, duration); }//from w w w. ja v a 2 s . c o m }); }
From source file:com.google.speedtracer.client.visualizations.model.ReportDataCollector.java
License:Apache License
public ReportData gatherDataWithinWindow(double leftBound, double rightBound) { Collector uiEventCollector = new Collector() { private List<HintRecord> hints = new ArrayList<HintRecord>(); @Override//from w ww.j a va2 s .co m void examineRecord(EventRecord record, JsIntegerDoubleMap out) { UiEvent castedRecord = record.cast(); AggregateTimeVisitor.apply(castedRecord); // Aggregate the type durations. Only UiEvents will have type // durations set. We simply ignore events without a duration map. JsIntegerDoubleMap typeDurations = castedRecord.getTypeDurations(); if (typeDurations != null) { doAggregation(typeDurations, out); } setTotalAvailableTime(getTotalAvailableTime() - castedRecord.getDuration()); addHintsFromJSOArray(record.getHintRecords(), hints); } @Override void finishCollection(JsIntegerDoubleMap aggregateDurationsOut, List<HintRecord> hintsOut) { // Add a wedge for the available time between top level records. aggregateDurationsOut.put(-1, getTotalAvailableTime()); hintsOut.addAll(hints); } }; Collector networkEventCollector = new Collector() { JsStringMap<JSOArray<HintRecord>> resourceHints = JsStringMap.create(); @Override void examineRecord(EventRecord record, JsIntegerDoubleMap out) { // We dont aggregate time, we simply track network resources. if (ResourceRecord.isResourceRecord(record)) { ResourceRecord resourceRecord = record.cast(); NetworkResource resource = dataDispatcher.getNetworkEventDispatcher() .getResource(resourceRecord.getRequestId()); if (resource != null) { resourceHints.put(resourceRecord.getRequestId(), resource.getHintRecords()); } } } @Override void finishCollection(JsIntegerDoubleMap aggregateDurationsOut, final List<HintRecord> hintsOut) { // Collect resource related hints that we placed inside the map. resourceHints.iterate(new JsStringMap.IterationCallBack<JSOArray<HintRecord>>() { public void onIteration(String key, JSOArray<HintRecord> resourceHints) { addHintsFromJSOArray(resourceHints, hintsOut); } }); } }; // Gather report for UiEvents. ReportData uiEventReport = gatherDataWithinWindowImpl(leftBound, rightBound, dataDispatcher.getUiEventDispatcher().getEventList(), uiEventCollector); // Gather report for Network Events. ReportData networkEventReport = gatherDataWithinWindowImpl(leftBound, rightBound, dataDispatcher.getNetworkEventDispatcher().getNetworkEvents(), networkEventCollector); return uiEventReport.combineWith(networkEventReport); }
From source file:com.google.speedtracer.client.visualizations.view.EventTraceBreakdown.java
License:Apache License
private void renderNode(Canvas canvas, UiEvent parent, UiEvent node, JsIntegerDoubleMap accumulatedErrorByType) { double startX = (node.getTime() - rootEvent.getTime()) * masterDomainToCoords; double width = node.getDuration() * masterDomainToCoords; final int nodeType = node.getType(); // Insignificance is tricky. If we have lots of insignificant things, they // can add up to a significant thing. if (node.getDuration() < insignificanceThreshold) { // When the sub-pixel strokes are composited, we get a misleading color // blend. We use a unique aliasing scheme here where we suppress short // duration events but keep up with the total time we've suppressed for // each suppressed type. If the total suppressed time for a type ends up // being significant, we will synthesize a single aggregate event to // correct our accounting. double correctedTime = node.getSelfTime(); if (accumulatedErrorByType.hasKey(nodeType)) { correctedTime += accumulatedErrorByType.get(nodeType); }//from ww w. j a v a 2 s . c o m if (correctedTime < insignificanceThreshold) { accumulatedErrorByType.put(nodeType, correctedTime); return; } // We want to draw a discrete bar. width = insignificanceThreshold * masterDomainToCoords; // Reset the type specific aggregation. accumulatedErrorByType.put(nodeType, 0); } canvas.setFillStyle(presenter.getColor(node)); canvas.fillRect(startX, 0, width, COORD_HEIGHT); }