Examples of PerfMetric


Examples of org.auraframework.test.perf.metrics.PerfMetric

public final class PerfGoldFilesUtilTest extends UnitTestCase {

    public void testPerfMetricsSerialization() throws Exception {
        // generate metrics gold file
        PerfMetrics metrics = new PerfMetrics();
        PerfMetric metric1 = new PerfMetric("metric1", 1);
        metric1.setDetails(new JSONArray("[{\"bytes\":\"3\"}]"));
        metrics.setMetric(metric1);
        metrics.setMetric(new PerfMetric("metric2", 2));
        String text = PerfGoldFilesUtil.toGoldFileText(metrics, true);

        // check the gold file is json-parseable
        JSONArray json = new JSONArray(text);
        assertEquals(3, json.length());

        // read metrics back
        PerfMetrics readMetrics = PerfGoldFilesUtil.fromGoldFileText(text);
        assertEquals(2, readMetrics.size());
        metric1 = readMetrics.getMetric("metric1");
        assertEquals(1, metric1.getIntValue());
        assertEquals(2, readMetrics.getMetric("metric2").getIntValue());

        JSONArray details = metric1.getDetails();
        assertEquals(3, details.getJSONObject(0).getInt("bytes"));
    }
View Full Code Here

Examples of org.auraframework.test.perf.metrics.PerfMetric

        Set<String> names = metrics.getAllMetricNames();
        for (String name : names) {
            if (sb.length() > 1) {
                sb.append("\n,");
            }
            PerfMetric metric = metrics.getMetric(name);
            JSONArray details = metric.getDetails();
            if (details != null) {
                metric.remove(PerfMetric.DETAILS);
            }
            sb.append(metrics.getMetric(name));
            if (details != null) {
                if (addDetails) {
                    sb.append("\n,");
                    // puts details in a separate line
                    JSONObject json = new JSONObject();
                    try {
                        json.put(name + ".details", details);
                    } catch (JSONException e) {
                        throw new RuntimeException(e);
                    }
                    sb.append(json);
                }
                metric.setDetails(details);
            }
        }
        sb.append(']');
        return sb.toString();
    }
View Full Code Here

Examples of org.auraframework.test.perf.metrics.PerfMetric

     */
    public static PerfMetrics fromGoldFileText(String text) throws IOException {
        PerfMetrics metrics = new PerfMetrics();
        BufferedReader reader = new BufferedReader(new StringReader(text));
        String line;
        PerfMetric lastMetric = null;
        while ((line = reader.readLine()) != null) {
            try {
                line = line.substring(1);
                if (line.endsWith("]")) {
                    line = line.substring(0, line.length() - 1);
                }
                if (lastMetric != null && line.startsWith("{\"" + lastMetric.getName() + ".details\":")) {
                    JSONObject details = new JSONObject(line);
                    lastMetric.setDetails(details.getJSONArray(lastMetric.getName() + ".details"));
                } else {
                    lastMetric = new PerfMetric(line);
                    metrics.setMetric(lastMetric);
                }
            } catch (JSONException e) {
                throw new RuntimeException(line, e);
            }
View Full Code Here

Examples of org.auraframework.test.perf.metrics.PerfMetric

        // UC: extract/verify Network metrics
        RDPAnalyzer analyzer = new RDPAnalyzer(notifications, getPerfStartMarker(), getPerfEndMarker());
        List<PerfMetric> networkMetrics = analyzer.analyzeNetworkDomain();
        // check requestsMetric
        PerfMetric requestsMetric = networkMetrics.get(0);
        assertEquals("Network.numRequests", requestsMetric.getName());
        int numRequests = requestsMetric.getIntValue();
        assertTrue("numRequests: " + numRequests, numRequests >= 6);
        // check bytes metric
        PerfMetric bytesMetric = networkMetrics.get(1);
        assertEquals("Network.encodedDataLength", bytesMetric.getName());
        assertEquals("bytes", bytesMetric.getUnits());
        assertTrue("bytes: " + bytesMetric.getIntValue() + ": " + bytesMetric.toString(), bytesMetric.getIntValue() > 0);
        JSONArray requests = bytesMetric.getDetails();
        assertTrue("num requests: " + requests.length(), requests.length() == numRequests);

        // UC: extract/verify Timeline event metrics
        Map<String, TimelineEventStats> timelineEventsStats = analyzer.analyzeTimelineDomain();
        TimelineEventStats paintStats = timelineEventsStats.get("Paint");
View Full Code Here

Examples of org.auraframework.test.perf.metrics.PerfMetric

            LOG.log(Level.INFO, "no matching loadingFinished/Failed found for: " + detail.toString());
            numRequests++;
            details.put(detail);
        }

        PerfMetric numRequestsMetric = new PerfMetric("Network.numRequests", numRequests);
        PerfMetric encodedDataLengthMetric = new PerfMetric("Network.encodedDataLength", totalEncodedDataLength,
                "bytes");
        numRequestsMetric.setDetails(details);
        encodedDataLengthMetric.setDetails(details);

        return Lists.newArrayList(numRequestsMetric, encodedDataLengthMetric);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.