Example usage for com.google.gwt.coreext.client JSOArray size

List of usage examples for com.google.gwt.coreext.client JSOArray size

Introduction

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

Prototype

public final native int size() ;

Source Link

Usage

From source file:com.google.speedtracer.client.model.AppStatsServerEvent.java

License:Apache License

private static JSOArray<UiEvent> toServerEvents(JSOArray<ApiEvent> apiEvents, double startTime) {
    final JSOArray<UiEvent> uiEvents = JSOArray.create();
    for (int i = 0, n = apiEvents.size(); i < n; ++i) {
        final ApiEvent apiEvent = apiEvents.get(i);
        uiEvents.push(ServerEvent.create(ServerEvent.TYPE, startTime + apiEvent.getStartTimeOffset(),
                apiEvent.getDuration(), ServerEvent.createDataBag(createLabel(apiEvent), "API"),
                JSOArray.<UiEvent>create()));
    }//from  w  ww.j a v a2 s . c o m
    return uiEvents;
}

From source file:com.google.speedtracer.client.model.HintRecord.java

License:Apache License

/**
 * Returns the most severe severity value found the list.
 * /* w w w. j  ava2  s . co m*/
 * @param hintRecords a list of Hintlet records to search.
 * @return the most severe severity value found in the list.
 */
public static int mostSevere(JSOArray<HintRecord> hintRecords) {
    int numRecs = hintRecords.size();
    int maxSeverity = HintRecord.SEVERITY_INFO;
    for (int i = 0; i < numRecs; i++) {
        int severity = hintRecords.get(i).getSeverity();
        if (severity < maxSeverity) {
            maxSeverity = severity;
        }
    }
    return maxSeverity;
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModel.java

License:Apache License

private String formatSymbolName(String symbolName) {
    JSOArray<String> vals = JSOArray.splitString(symbolName, " ");
    StringBuilder result = new StringBuilder();
    for (int i = 0, length = vals.size(); i < length; ++i) {
        String val = vals.get(i);
        if (val.startsWith("http://") || val.startsWith("https://") || val.startsWith("file://")
                || val.startsWith("chrome://") || val.startsWith("chrome-extension://")) {
            // Presenting the entire URL takes too much space. Just show the
            // last path component.
            String resource = val.substring(val.lastIndexOf("/") + 1);

            resource = "".equals(resource) ? val : resource;
            result.append(resource);// w ww. j  a  v a 2s. co m
        } else {
            result.append(val);
        }
        result.append(" ");
    }
    return result.toString();
}

From source file:com.google.speedtracer.client.model.JavaScriptProfileModelV8Impl.java

License:Apache License

/**
 * Process a portion of the logLines array. If the workQueue is enabled, exit
 * early if the timeslice expires./* w  ww. j  av  a2s  .  co  m*/
 */
private void processLogLines(final UiEvent refRecord, final JSOArray<String> logLines, int currentLine) {
    final int logLinesLength = logLines.size();

    for (; currentLine < logLinesLength; ++currentLine) {
        if (workQueue != null) {
            // Occasionally check to see if the time to run this chunk has expired.
            if ((currentLine % 10 == 0) && workQueue.isTimeSliceExpired()) {
                break;
            }
        }

        String logLine = logLines.get(currentLine);
        if (logDecompressor != null && logLine.length() > 0) {
            logLine = logDecompressor.decompressLogEntry(logLine);
        }
        JsArrayString decompressedLogLine = Csv.split(logLine);
        if (decompressedLogLine.length() > 0) {
            parseLogEntry(decompressedLogLine);
        }

        // force gc on processed log lines.
        logLines.set(currentLine, null);
    }

    if (currentLine < logLinesLength) {
        // Schedule this record to be the next thing run off the queue
        workQueue.prepend(new LogLineWorker(logLines, refRecord, currentLine));
    } else {
        // All done!
        if (currentProfile.getProfile(JavaScriptProfile.PROFILE_TYPE_BOTTOM_UP) == null) {
            if (refRecord != null) {
                refRecord.setHasJavaScriptProfile(false);
            }
        } else {
            if (refRecord != null) {
                refRecord.setHasJavaScriptProfile(true);
            }
        }
    }
}

From source file:com.google.speedtracer.client.model.NetworkEventDispatcher.java

License:Apache License

/**
 * @param identifier Resource ID//from   w w  w  .  j  a v a2s .c  o m
 * @param url The redirect URL that we are using to match a redirect
 *        candidate.
 */
private NetworkResource findAndRemoveRedirectCandidate(String identifier, String url) {
    // Look for it.
    JSOArray<NetworkResource> redirectCandidates = redirects.get(identifier);
    if (redirectCandidates == null) {
        return null;
    }

    for (int i = 0; i < redirectCandidates.size(); i++) {
        NetworkResource redirectCandidate = redirectCandidates.get(i);
        if (redirectCandidate.getUrl().equals(url)) {
            // Should not be a concurrent modification, since we now bail out of
            // the loop right after mutating the queue.
            redirectCandidates.splice(i, 1);
            return redirectCandidate;
        }
    }

    return null;
}

From source file:com.google.speedtracer.client.model.NetworkResource.java

License:Apache License

/**
 * Accumulates and returns any hints that were associated with records for
 * this network resource./*from   w  ww.ja v a2s .  c om*/
 * 
 * @return JSOArray of HintRecords.
 */
public JSOArray<HintRecord> getHintRecords() {
    JSOArray<HintRecord> hints = JSOArray.createArray().cast();

    if (startEvent.hasHintRecords()) {
        hints = hints.concat(startEvent.getHintRecords());
    }

    if (responseEvent != null && responseEvent.hasHintRecords()) {
        hints = hints.concat(responseEvent.getHintRecords());
    }

    if (finishEvent != null && finishEvent.hasHintRecords()) {
        hints = hints.concat(finishEvent.getHintRecords());
    }

    if (hints.size() <= 0) {
        return null;
    }

    return hints;
}

From source file:com.google.speedtracer.client.model.SpringInsightServerEvent.java

License:Apache License

private static ServerEvent toServerEvent(NetworkResource resource, double traceStartTime, Frame frame) {
    final JSOArray<Frame> frames = frame.getChildren();
    final JSOArray<UiEvent> events = JSOArray.create();
    for (int i = 0, n = frames.size(); i < n; ++i) {
        events.push(toServerEvent(resource, traceStartTime, frames.get(i)));
    }// ww  w. j  a va  2s .  c o  m
    final double startTime = resource.getStartTime();
    final Range range = frame.getRange();
    final Operation operation = frame.getOperation();
    return ServerEvent.create(EventRecordType.SERVER_EVENT, startTime + (range.getStart() - traceStartTime),
            range.getDuration(), ServerEvent.createDataBag(operation.getLabel(), operation.getType()), events);
}

From source file:com.google.speedtracer.client.model.UiEvent.java

License:Apache License

private static <T> T apply(LeafFirstTraversal<T> visitor, UiEvent event) {
    final JSOArray<T> values = JSOArray.create();
    final JSOArray<UiEvent> children = event.getChildren();
    for (int i = 0, n = children.size(); i < n; ++i) {
        values.push(apply(visitor, children.get(i)));
    }//from   w w  w .  java  2  s. com
    return visitor.visit(event, values);
}

From source file:com.google.speedtracer.client.model.UiEvent.java

License:Apache License

private static double apply(LeafFirstTraversalNumber visitor, UiEvent event) {
    final JsArrayNumber values = JsArrayNumber.createArray().cast();
    final JSOArray<UiEvent> children = event.getChildren();
    for (int i = 0, n = children.size(); i < n; ++i) {
        values.push(apply(visitor, children.get(i)));
    }/*from  www  .  jav a  2 s .c  o m*/
    return visitor.visit(event, values);
}

From source file:com.google.speedtracer.client.model.UiEvent.java

License:Apache License

private static void apply(LeafFirstTraversalVoid visitor, UiEvent event) {
    final JSOArray<UiEvent> children = event.getChildren();
    for (int i = 0, n = children.size(); i < n; ++i) {
        apply(visitor, children.get(i));
    }/*from ww w . java  2s  .  c o  m*/
    visitor.visit(event);
}