コード例 #1
0
ファイル: PerfMetrics.java プロジェクト: synle/aura
 public JSONArray toJSONArrayWithoutDetails() {
   try {
     PerfMetrics metricsWithoutDetails =
         PerfGoldFilesUtil.fromGoldFileText(PerfGoldFilesUtil.toGoldFileText(this, false));
     JSONArray array = new JSONArray();
     for (String name : metricsWithoutDetails.getAllMetricNames()) {
       array.put(metricsWithoutDetails.getMetric(name));
     }
     return array;
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
コード例 #2
0
ファイル: PerfMetrics.java プロジェクト: synle/aura
 /** @return number of metrics that are the same as the ones in the other PerfMetrics object */
 public int numSame(PerfMetrics other) {
   int numSame = 0;
   for (String name : metrics.keySet()) {
     if (getMetric(name).equals(other.getMetric(name))) {
       numSame++;
     }
   }
   return numSame;
 }
コード例 #3
0
ファイル: PerfMetrics.java プロジェクト: synle/aura
  /**
   * Combines the metrics from multiple metrics objects into a single one. If a metric appears in
   * more than one metric object the first metric value found is used.
   */
  public static PerfMetrics combine(PerfMetrics... metricsList) {
    PerfMetrics combined = null;
    List<JSONObject> devToolsLog = null;
    Map<String, ?> jsProfilerData = null;
    Map<String, ?> heapSnapshot = null;

    for (PerfMetrics metrics : metricsList) {
      if (metrics != null) {
        if (devToolsLog == null) {
          devToolsLog = metrics.getDevToolsLog();
        }
        if (jsProfilerData == null) {
          jsProfilerData = metrics.getJSProfilerData();
        }
        if (heapSnapshot == null) {
          heapSnapshot = metrics.getHeapSnapshot();
        }
        if (combined == null) {
          // so we return null if all metrics in metricsList are null
          combined = new PerfMetrics();
        }
        for (String name : metrics.getAllMetricNames()) {
          if (!combined.hasMetric(name)) {
            combined.setMetric(metrics.getMetric(name));
          }
        }
      }
    }
    if (combined != null) {
      combined.setDevToolsLog(devToolsLog);
      combined.setJSProfilerData(jsProfilerData);
      combined.setHeapSnapshot(heapSnapshot);
    }
    return combined;
  }