Package com.google.json.serialization

Examples of com.google.json.serialization.JsonObject$Iter


    json.put("duration", (long) newDuration);
    json.put("end", (long) (newStartTime + newDuration));
  }

  private static JsonObject scaleTrace(JsonObject data, int duration) {
    final JsonObject trace = data.get("trace").asObject();
    // Get the top-level range.
    final JsonObject range = trace.get("range").asObject();

    final long startTime = getRangeStartTime(range);

    // Compute the scaling factor.
    final double scaleFactor = (double) duration
View Full Code Here


  // TODO(conroy): refactor this and the other analyzers to use a visitor (for
  // a single pass on the data)
  public void analyze() throws JsonException {
    List<JsonObject> logRecords = speedTraceAnalyzer.findRecordsByType(EventRecordType.LOG_MESSAGE_EVENT);
    for (JsonObject logRecord : logRecords) {
      JsonObject dataObject = logRecord.get("data").asObject();
      String message = dataObject.get("message").asString().getString();
      if (message.startsWith(prefix)) {
        try {
          String embeddedJson = message.substring(prefix.length());
          JsonObject timelineObject = JsonObject.parse(new StringReader(
              embeddedJson));
          analyzeTimelineMessage(timelineObject,
              logRecord.get("time").asNumber().getDecimal());
        } catch (IOException ex) {
          System.err.println("Huh? IO Exception? " + ex);
View Full Code Here

  }

  private void calcSelfTime() throws JsonException {
    SelfTimeVisitor selfTimeVisitor = new SelfTimeVisitor();
    for (int i = 0, length = records.getLength(); i < length; ++i) {
      JsonObject record = records.get(i).asObject();
      JsonTraverser.get().traverse(record, selfTimeVisitor);
    }
  }
View Full Code Here

    }
  }

  private double findMainResourceResponseTime() {
    for (int i = this.mainResourceStartIndex, length = records.getLength(); i < length; ++i) {
      JsonObject topLevelRec = records.get(i).asObject();
      long type = topLevelRec.get("type").asNumber().getInteger();
      if (type == EventRecordType.RESOURCE_RECEIVE_RESPONSE
          || type == EventRecordType.RESOURCE_DATA_RECEIVED
          || type == EventRecordType.RESOURCE_FINISH) {
        JsonObject data = topLevelRec.get("data").asObject();
        if (data == JsonValue.NULL) {
          throw new AnalyzeException(
              "Expected data object in RESOURCE_RECEIVE_RESPONSE");
        }
        long identifier = data.get("identifier").asNumber().getInteger();
        if (this.mainResourceIdentfier == identifier) {
          return topLevelRec.get("time").asNumber().getDecimal();
        }
      }
    }
View Full Code Here

            + this.mainResourceStartIndex + " and " + records.getLength() + ".");
  }

  private int findMainResourceStartTime() {
    for (int i = 0, length = records.getLength(); i < length; ++i) {
      JsonObject topLevelRec = records.get(i).asObject();
      long type = topLevelRec.get("type").asNumber().getInteger();
      if (type == EventRecordType.RESOURCE_SEND_REQUEST) {
        JsonObject data = topLevelRec.get("data").asObject();
        if (data == JsonValue.NULL) {
          throw new AnalyzeException(
              "Expected data object in RESOURCE_SEND_REQUEST");
        }
        JsonValue isMainResource = data.get("isMainResource");
        JsonValue identifier = data.get("identifier");
        if (isMainResource != null && isMainResource != JsonValue.NULL
            && identifier != null && identifier != JsonValue.NULL) {
          this.mainResourceIdentfier = identifier.asNumber().getInteger();
          this.mainResourceStartTime = topLevelRec.get("time").asNumber().getDecimal();
          // System.out.println("Found: " + data);
View Full Code Here

  private final String revision;
  private final long timeStamp;

  public SpeedTraceRecord(String rawData) throws JsonException {
    this.rawData = rawData;
    JsonObject headerObject = getHeaderObject();
    timeStamp = (long) headerObject.get("timeStamp").asNumber().getDecimal();
    name = headerObject.get("name").asString().getString();
    revision = headerObject.get("revision").asString().getString();
  }
View Full Code Here

  private void analyzeLogRecords() throws JsonException {
    List<JsonObject> logRecords = speedTraceAnalyzer.findRecordsByType(EventRecordType.LOG_MESSAGE_EVENT);

    for (JsonObject logRecord : logRecords) {
      JsonObject dataObject = logRecord.get("data").asObject();
      String message = dataObject.get("message").asString().getString();
      if (message.startsWith(GWT_LIGHTWEIGHT_STATS_PREFIX)) {
        try {
          String embeddedJson = message.substring(GWT_LIGHTWEIGHT_STATS_PREFIX.length());
          JsonObject messageObject = JsonObject.parse(new StringReader(
              embeddedJson));
          analyzeLightweightMetric(messageObject,
              logRecord.get("time").asNumber().getDecimal());
        } catch (IOException ex) {
          System.err.println("Huh? IO Exception? " + ex);
View Full Code Here

TOP

Related Classes of com.google.json.serialization.JsonObject$Iter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.