lttng: Convert performance results from Derby to JSON
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 8 Jul 2014 23:38:20 +0000 (19:38 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Wed, 30 Jul 2014 15:23:07 +0000 (11:23 -0400)
The performance tests and conversion can be executed from the command line:
mvn clean install -Pperformance

To connect to the database, additional properties have to be set.
See perf.database.loc and perf.config in
org.eclipse.linuxtools.lttng.alltests/pom.xml

A destination can also be specified with -DperfFilesDestination

Change-Id: I70b83b151d739eee7964cceef3f2b3d8078561b9
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/29644
Tested-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
org.eclipse.linuxtools.lttng.alltests/.gitignore [new file with mode: 0644]
org.eclipse.linuxtools.lttng.alltests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng.alltests/pom.xml [new file with mode: 0644]
org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/Activator.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/PerfResultsToJSon.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.target/lttng-e3.8.target
org.eclipse.linuxtools.lttng.target/lttng-e4.2.target
org.eclipse.linuxtools.lttng.target/lttng-e4.3.target
org.eclipse.linuxtools.lttng.target/lttng-e4.4.target
org.eclipse.linuxtools.lttng.target/lttng-eStaging.target
pom.xml

diff --git a/org.eclipse.linuxtools.lttng.alltests/.gitignore b/org.eclipse.linuxtools.lttng.alltests/.gitignore
new file mode 100644 (file)
index 0000000..94a2dd1
--- /dev/null
@@ -0,0 +1 @@
+*.json
\ No newline at end of file
index c3896282fe00c030a4e0652167e9403fbaa426c9..6335eab26224c3c913cb30ed1cf823a8a928d637 100644 (file)
@@ -8,6 +8,8 @@ Bundle-SymbolicName: org.eclipse.linuxtools.lttng.alltests;singleton:=true
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.junit;bundle-version="4.0.0",
+ org.eclipse.core.runtime,
+ org.eclipse.test.performance,
  org.eclipse.linuxtools.ctf.core.tests;bundle-version="2.1.0",
  org.eclipse.linuxtools.gdbtrace.core.tests;bundle-version="1.1.0",
  org.eclipse.linuxtools.gdbtrace.ui.tests;bundle-version="1.1.0",
@@ -30,3 +32,6 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.linuxtools.tmf.analysis.xml.ui.tests;bundle-version="1.0.0",
  org.eclipse.linuxtools.pcap.core.tests;bundle-version="3.0.0"
 Export-Package: org.eclipse.linuxtools.lttng.alltests;x-internal:=true
+Import-Package: org.apache.derby.jdbc,
+ org.json
+Bundle-Activator: org.eclipse.linuxtools.lttng.alltests.Activator
diff --git a/org.eclipse.linuxtools.lttng.alltests/pom.xml b/org.eclipse.linuxtools.lttng.alltests/pom.xml
new file mode 100644 (file)
index 0000000..f3131a3
--- /dev/null
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Copyright (C) 2014 Ericsson
+
+   All rights reserved. This program and the accompanying materials
+   are made available under the terms of the Eclipse Public License v1.0
+   which accompanies this distribution, and is available at
+   http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <artifactId>linuxtools-lttng-parent</artifactId>
+    <groupId>org.eclipse.linuxtools.lttng</groupId>
+    <version>3.1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>org.eclipse.linuxtools.lttng.alltests</artifactId>
+  <version>3.0.0-SNAPSHOT</version>
+  <packaging>eclipse-test-plugin</packaging>
+
+  <name>Linux Tools LTTng Component All Tests</name>
+
+  <properties>
+    <perf.database.loc>//127.0.0.1</perf.database.loc>
+    <perf.config>build=20140707-1632;host=myhost;config=linux;jvm=1.7</perf.config>
+    <perfFilesDestination>target</perfFilesDestination>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.eclipse.tycho</groupId>
+        <artifactId>tycho-surefire-plugin</artifactId>
+        <version>${tycho-version}</version>
+        <configuration>
+          <argLine>${tycho.testArgLine} -Declipse.perf.dbloc=${perf.database.loc} -Declipse.perf.config=${perf.config}</argLine>
+          <runOrder>reversealphabetical</runOrder>
+          <includes>
+              <include>**/RunAllPerfTests.java</include>
+              <include>**/PerfResultsToJSon.java</include>
+          </includes>
+          <useUIHarness>false</useUIHarness>
+          <useUIThread>false</useUIThread>
+          <product>org.eclipse.platform.ide</product>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>deploy-performance-files</id>
+            <phase>install</phase>
+              <goals>
+                <goal>run</goal>
+              </goals>
+              <configuration>
+              <target>
+                <copy includeemptydirs="false"
+                  todir="${perfFilesDestination}">
+                  <fileset dir=".">
+                    <include name="*.json" />
+                    <include name="*.js" />
+                  </fileset>
+                </copy>
+              </target>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- We don't use the ant file to clean because of http://jira.codehaus.org/browse/MANTRUN-78 -->
+      <plugin>
+        <artifactId>maven-clean-plugin</artifactId>
+        <version>2.5</version>
+        <executions>
+          <execution>
+            <id>clean-performance-files</id>
+            <phase>clean</phase>
+            <configuration>
+              <filesets>
+                <fileset>
+                  <directory>.</directory>
+                  <includes>
+                    <include>*.json</include>
+                    <include>*.js</include>
+                  </includes>
+                </fileset>
+              </filesets>
+            </configuration>
+            <goals>
+              <goal>clean</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/Activator.java b/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/Activator.java
new file mode 100644 (file)
index 0000000..a159ffe
--- /dev/null
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Marc-Andre Laperle - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.alltests;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle. No more than one such
+ * plug-in can exist at any time.
+ * <p>
+ * It also provides the plug-in's general logging facility and manages the
+ * internal tracer.
+ */
+public class Activator extends Plugin {
+
+    /**
+     * The plug-in ID
+     */
+    public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng.alltests"; //$NON-NLS-1$
+
+    /**
+     * The shared instance
+     */
+    private static Activator fPlugin;
+
+    /**
+     * Constructor
+     */
+    public Activator() {
+        setDefault(this);
+    }
+
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
+
+    /**
+     * Returns the AllTests plug-in instance.
+     *
+     * @return the AllTests plug-in instance.
+     */
+    public static Activator getDefault() {
+        return fPlugin;
+    }
+
+    // Sets plug-in instance
+    private static void setDefault(Activator plugin) {
+        fPlugin = plugin;
+    }
+
+    // ------------------------------------------------------------------------
+    // Plugin
+    // ------------------------------------------------------------------------
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        super.start(context);
+        setDefault(this);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        setDefault(null);
+        super.stop(context);
+    }
+
+
+    /**
+     * Log an IStatus object directly
+     *
+     * @param status
+     *            The status to log
+     */
+    public static void log(IStatus status) {
+        fPlugin.getLog().log(status);
+    }
+
+    // ------------------------------------------------------------------------
+    // Log INFO
+    // ------------------------------------------------------------------------
+
+    /**
+     * Logs a message with severity INFO in the runtime log of the plug-in.
+     *
+     * @param message
+     *            A message to log
+     */
+    public static void logInfo(String message) {
+        fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
+    }
+
+    /**
+     * Logs a message and exception with severity INFO in the runtime log of the
+     * plug-in.
+     *
+     * @param message
+     *            A message to log
+     * @param exception
+     *            The corresponding exception
+     */
+    public static void logInfo(String message, Throwable exception) {
+        fPlugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message, exception));
+    }
+
+    // ------------------------------------------------------------------------
+    // Log WARNING
+    // ------------------------------------------------------------------------
+
+    /**
+     * Logs a message and exception with severity WARNING in the runtime log of
+     * the plug-in.
+     *
+     * @param message
+     *            A message to log
+     */
+    public static void logWarning(String message) {
+        fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message));
+    }
+
+    /**
+     * Logs a message and exception with severity WARNING in the runtime log of
+     * the plug-in.
+     *
+     * @param message
+     *            A message to log
+     * @param exception
+     *            The corresponding exception
+     */
+    public static void logWarning(String message, Throwable exception) {
+        fPlugin.getLog().log(new Status(IStatus.WARNING, PLUGIN_ID, message, exception));
+    }
+
+    // ------------------------------------------------------------------------
+    // Log ERROR
+    // ------------------------------------------------------------------------
+
+    /**
+     * Logs a message and exception with severity ERROR in the runtime log of
+     * the plug-in.
+     *
+     * @param message
+     *            A message to log
+     */
+    public static void logError(String message) {
+        fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
+    }
+
+    /**
+     * Logs a message and exception with severity ERROR in the runtime log of
+     * the plug-in.
+     *
+     * @param message
+     *            A message to log
+     * @param exception
+     *            The corresponding exception
+     */
+    public static void logError(String message, Throwable exception) {
+        fPlugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/PerfResultsToJSon.java b/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/PerfResultsToJSon.java
new file mode 100644 (file)
index 0000000..962071e
--- /dev/null
@@ -0,0 +1,624 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.alltests;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.test.internal.performance.PerformanceTestPlugin;
+import org.eclipse.test.internal.performance.data.Dim;
+import org.eclipse.test.internal.performance.db.DB;
+import org.eclipse.test.internal.performance.db.Scenario;
+import org.eclipse.test.internal.performance.db.SummaryEntry;
+import org.eclipse.test.internal.performance.db.TimeSeries;
+import org.eclipse.test.internal.performance.db.Variations;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
+
+/**
+ * Convert results from the database to JSON suitable for display.
+ *
+ * Normal charts:
+ *
+ * Individual charts are generated into JSON files in the form chart#.json where
+ * # is incremented for each new chart. A chart contains data points consisting
+ * of X and Y values suitable for a line chart. Each point can also have
+ * additional data, for example the commit id. This format is compatible with
+ * nvd3. For example:
+ *
+ * <pre>
+ * <code>
+ * [{
+ *   "key": "Experiment Benchmark:84 traces",
+ *   "values": [{
+ *       "label": {"commit": "fe3c142"},
+ *       "x": 1405024320000,
+ *       "y": 17592
+ *   }]
+ * }]
+ * </code>
+ * </pre>
+ *
+ * Normal charts metadata:
+ *
+ * Each chart has an entry in the metada.js file which organizes the charts per
+ * component and contains additional information to augment the format expected
+ * by nvd3. Each entry contains the combination of OS and JVM, the filename (in
+ * JSON format), the title of the chart, the unit (seconds, etc) and the
+ * dimension (CPU time, used heap, etc).
+ *
+ * <pre>
+ *  <code>
+ *  var MetaData = {
+ *     "applicationComponents": {
+ *         "Experiment benchmark": {
+ *             "name": "Experiment benchmark",
+ *             "tests": [
+ *                 {
+ *                     "dimension": "CPU Time",
+ *                     "file": "chart12",
+ *                     "jvm": "1.7",
+ *                     "os": "linux",
+ *                     "title": "Experiment Benchmark:84 traces",
+ *                     "unit": "s"
+ *                 },
+ *                 {
+ *                     "dimension": "CPU Time",
+ *                     "file": "chart11",
+ *                     "jvm": "1.7",
+ *                     "os": "linux",
+ *                     "title": "Experiment Benchmark:6 traces",
+ *                     "unit": "s"
+ *                 },
+ * ...
+ *  </code>
+ * </pre>
+ *
+ * Overview charts:
+ *
+ * In addition to the normal charts, overview charts are generated. An overview
+ * chart presents a summary of the scenarios ran for a given OS and JVM
+ * combination. Only scenarios marked as "global" are added to the overview
+ * because of space concerns. Overview charts are generated under the
+ * chart_overview#.json name and look similar in structure to the normal charts
+ * except that they contain more than one series.
+ *
+ * <pre>
+ *   <code>
+ * [
+ *   {
+ *       "key": "CTF Read & Seek Benchmark (500 seeks):tr",
+ *       "values": [
+ *           {
+ *               "label": {"commit": "4d34345"},
+ *               "x": 1405436820000,
+ *               "y": 5382.5
+ *           },
+ *           ...
+ *       ]
+ *   },
+ *   {
+ *       "key": "CTF Read Benchmark:trace-kernel",
+ *       "values": [
+ *           {
+ *               "label": {"commit": "4d34345"},
+ *               "x": 1405436820000,
+ *               "y": 1311.5
+ *           },
+ *           ...
+ *       ]
+ *   },
+ *   ...
+ *   </code>
+ * </pre>
+ *
+ * Overview charts metadata:
+ *
+ * Overview charts also have similar metadata entries to normal charts except
+ * they are not organized by component.
+ *
+ * <pre>
+ *   <code>
+ * var MetaData = {
+ * ...
+ *   "overviews": {
+ *       "1": {
+ *           "dimension": "",
+ *           "file": "chart_overview0",
+ *           "jvm": "1.7",
+ *           "os": "linux",
+ *           "title": "linux / 1.7",
+ *           "unit": ""
+ *       },
+ *       "2": {
+ *           "dimension": "",
+ *           "file": "chart_overview1",
+ *           "jvm": "1.7",
+ *           "os": "windows",
+ *           "title": "windows / 1.7",
+ *           "unit": ""
+ *       },
+ *       ...
+ *   </code>
+ * </pre>
+ *
+ * Finally, since we want to be able to filter all the charts by OS/JVM
+ * combination, there is a section in the metadata that lists all the
+ * combinations:
+ *
+ * <pre>
+ *   <code>
+ *     "osjvm": {
+ *       "1": {
+ *           "description": "linux / 1.7",
+ *           "jvm": "1.7",
+ *           "os": "linux"
+ *       },
+ *       "2": {
+ *           "description": "windows / 1.7",
+ *           "jvm": "1.7",
+ *           "os": "windows"
+ *       },
+ *       "3": {
+ *           "description": "mac / 1.7",
+ *           "jvm": "1.7",
+ *           "os": "mac"
+ *       }
+ *   },
+ *   </code>
+ * </pre>
+ *
+ * All of this data is meant to be view on a website. Specifically, the source
+ * code for our implementation is available on GitHub at
+ * https://github.com/PSRCode/ITCFYWebsite
+ *
+ * It makes use of the NVD3 project to display the charts based on the data
+ * generated by this class.
+ */
+public class PerfResultsToJSon {
+
+    /*
+     * Labels
+     */
+    private static final String APPLICATION_COMPONENTS_LABEL = "applicationComponents";
+    private static final String BUILD_LABEL = "build";
+    private static final String COMMIT_LABEL = "commit";
+    private static final String CONFIG_LABEL = "config";
+    private static final String DESCRIPTION_LABEL = "description";
+    private static final String DIMENSION_LABEL = "dimension";
+    private static final String FILE_LABEL = "file";
+    private static final String HOST_LABEL = "host";
+    private static final String JVM_LABEL = "jvm";
+    private static final String KEY_LABEL = "key";
+    private static final String LABEL_LABEL = "label";
+    private static final String NAME_LABEL = "name";
+    private static final String OS_LABEL = "os";
+    private static final String OSJVM_LABEL = "osjvm";
+    private static final String OVERVIEWS_LABEL = "overviews";
+    private static final String TESTS_LABEL = "tests";
+    private static final String TITLE_LABEL = "title";
+    private static final String UNIT_LABEL = "unit";
+    private static final String VALUES_LABEL = "values";
+    private static final String X_LABEL = "x";
+    private static final String Y_LABEL = "y";
+
+    private static final String BUILD_DATE_FORMAT = "yyyyMMdd-HHmm";
+    private static final String OVERVIEW_CHART_FILE_NAME = "chart_overview";
+    private static final String METADATA_FILE_NAME = "meta";
+    private static final String METADATA_FILE_NAME_EXTENSION = ".js";
+    private static final String CHART_FILE_NAME = "chart";
+    private static final String CHART_FILE_NAME_EXTENSION = ".json";
+    private static final String WILDCARD_PATTERN = "%";
+    private static final String COMPONENT_SEPARATOR = "#";
+    private static final String META_DATA_JAVASCRIPT_START = "var MetaData = ";
+
+    private static Pattern BUILD_DATE_PATTERN = Pattern.compile("(\\w+-\\w+)(-\\w+)?");
+    private static Pattern COMMIT_PATTERN = Pattern.compile(".*-.*-(.*)");
+
+    private JSONObject fApplicationComponents = new JSONObject();
+    private JSONObject fOverviews = new JSONObject();
+
+    private int fNumChart = 0;
+    private int fNumOverviewChart = 0;
+
+    /**
+     * Convert results from the database to JSON suitable for display
+     *
+     * <pre>
+     * For each variant (os/jvm combination)
+     *    - For each summary entry (scenario)
+     *      - Generate a chart
+     *      - Add it to global summary (if needed)
+     *      - Create the metadata for this test
+     *    - Create an overview chart for this os/jvm
+     * </pre>
+     *
+     * @throws JSONException
+     *             JSON error
+     * @throws IOException
+     *             IO error
+     */
+    @Test
+    public void parseResults() throws JSONException, IOException {
+        Variations configVariations = PerformanceTestPlugin.getVariations();
+        JSONObject osJvmVariants = createOsJvm();
+
+        @SuppressWarnings("rawtypes")
+        Iterator keysIt = osJvmVariants.keys();
+        while (keysIt.hasNext()) {
+            JSONArray overviewSummarySeries = new JSONArray();
+
+            JSONObject variant = osJvmVariants.getJSONObject((String) keysIt.next());
+            String seriesKey = PerformanceTestPlugin.BUILD;
+
+            // Clone the variations from the environment because it might have
+            // extra parameters like host=, etc.
+            Variations buildVariations = (Variations) configVariations.clone();
+            buildVariations.setProperty(JVM_LABEL, variant.getString(JVM_LABEL));
+            buildVariations.setProperty(CONFIG_LABEL, variant.getString(OS_LABEL));
+            buildVariations.setProperty(BUILD_LABEL, WILDCARD_PATTERN);
+
+            Scenario[] scenarios = DB.queryScenarios(buildVariations, WILDCARD_PATTERN, seriesKey, null);
+            SummaryEntry[] summaryEntries = DB.querySummaries(buildVariations, WILDCARD_PATTERN);
+            for (SummaryEntry entry : summaryEntries) {
+                Scenario scenario = getScenario(entry.scenarioName, scenarios);
+                JSONObject scenarioSeries = createScenarioChart(scenario, entry, buildVariations);
+                // Add to global summary
+                if (scenarioSeries != null && entry.isGlobal) {
+                    overviewSummarySeries.put(scenarioSeries);
+                }
+            }
+
+            JSONObject overviewMetadata = createOverviewChart(overviewSummarySeries, buildVariations);
+            fOverviews.put(Integer.toString(fNumOverviewChart), overviewMetadata);
+        }
+
+        // Create the matadata javascript file that includes OS/JVM combinations
+        // (for filtering), application components and overviews (one of OS/JVM
+        // combination)
+        JSONObject rootMetadata = new JSONObject();
+        rootMetadata.put(OSJVM_LABEL, osJvmVariants);
+        rootMetadata.put(APPLICATION_COMPONENTS_LABEL, fApplicationComponents);
+        rootMetadata.put(OVERVIEWS_LABEL, fOverviews);
+        try (FileWriter fw1 = new FileWriter(METADATA_FILE_NAME + METADATA_FILE_NAME_EXTENSION)) {
+            fw1.write(META_DATA_JAVASCRIPT_START + rootMetadata.toString(4));
+        }
+    }
+
+    /**
+     * Create chart for a scenario instance and add it to the relevant metadatas
+     *
+     * @param scenario
+     *            the scenario. For example,
+     *            "CTF Read & Seek Benchmark (500 seeks)".
+     * @param entry
+     *            an entry from the summary. Only scenarios that are part of the
+     *            summary are processed.
+     * @param variations
+     *            all variations to consider to create the scenario chart. For
+     *            example build=%;jvm=1.7;config=linux will generate a chart for
+     *            all builds on Linux / JVM 1.7
+     *
+     * @return
+     * @throws JSONException
+     *             JSON error
+     * @throws IOException
+     *             IO error
+     */
+    private JSONObject createScenarioChart(Scenario scenario, SummaryEntry entry, Variations variations) throws JSONException, IOException {
+        if (scenario == null) {
+            return null;
+        }
+        String[] split = entry.scenarioName.split(COMPONENT_SEPARATOR);
+        if (split.length < 3) {
+            Activator.logError("Invalid scenario name \"" + entry.scenarioName + "\", it must be in format: org.package.foo#component#test");
+            return null;
+        }
+
+        // Generate individual chart
+        JSONArray rootScenario = new JSONArray();
+        JSONObject series = createSerie(scenario, variations, entry.shortName, entry.dimension);
+        rootScenario.put(series);
+        int numChart = fNumChart++;
+        try (FileWriter fw = new FileWriter(CHART_FILE_NAME + numChart + CHART_FILE_NAME_EXTENSION)) {
+            fw.write(rootScenario.toString(4));
+        }
+
+        // Create the metadata
+        JSONObject testMetadata = new JSONObject();
+        testMetadata.put(TITLE_LABEL, entry.shortName);
+        testMetadata.put(FILE_LABEL, CHART_FILE_NAME + numChart);
+        testMetadata.put(OS_LABEL, variations.getProperty(CONFIG_LABEL));
+        testMetadata.put(JVM_LABEL, variations.getProperty(JVM_LABEL));
+        testMetadata.put(DIMENSION_LABEL, entry.dimension.getName());
+        testMetadata.put(UNIT_LABEL, entry.dimension.getUnit().getShortName());
+
+        // Add the scenario to the metadata, under the correct component
+        String componentName = split[1];
+        JSONObject componentObject = null;
+        if (fApplicationComponents.has(componentName)) {
+            componentObject = fApplicationComponents.getJSONObject(componentName);
+        } else {
+            componentObject = new JSONObject();
+            componentObject.put(NAME_LABEL, componentName);
+            componentObject.put(TESTS_LABEL, new JSONArray());
+            fApplicationComponents.put(componentName, componentObject);
+        }
+        JSONArray tests = componentObject.getJSONArray(TESTS_LABEL);
+        tests.put(testMetadata);
+
+        return series;
+    }
+
+    /**
+     * Create an overview chart for this OS / JVM combination. The chart is made
+     * of multiple series (scenarios) that were marked as global.
+     *
+     * @param overviewSummarySeries
+     *            an array of series to include in the chart (multiple
+     *            scenarios)
+     * @param variations
+     *            the variations used to generate the series to be included in
+     *            this overview chart. For example build=%;jvm=1.7;config=linux
+     *            will generate an overview chart for Linux / JVM 1.7
+     * @return the overview metadata JSON object
+     * @throws JSONException
+     *             JSON error
+     * @throws IOException
+     *             io error
+     */
+    private JSONObject createOverviewChart(JSONArray overviewSummarySeries, Variations variations) throws IOException, JSONException {
+        int numOverviewChart = fNumOverviewChart++;
+        try (FileWriter fw = new FileWriter(OVERVIEW_CHART_FILE_NAME + numOverviewChart + CHART_FILE_NAME_EXTENSION)) {
+            fw.write(overviewSummarySeries.toString(4));
+        }
+
+        String os = variations.getProperty(CONFIG_LABEL);
+        String jvm = variations.getProperty(JVM_LABEL);
+
+        // Create the overview metadata
+        JSONObject overviewMetadata = new JSONObject();
+        overviewMetadata.put(TITLE_LABEL, os + " / " + jvm);
+        overviewMetadata.put(FILE_LABEL, OVERVIEW_CHART_FILE_NAME + numOverviewChart);
+        overviewMetadata.put(OS_LABEL, os);
+        overviewMetadata.put(JVM_LABEL, jvm);
+        overviewMetadata.put(DIMENSION_LABEL, "");
+        overviewMetadata.put(UNIT_LABEL, "");
+
+        return overviewMetadata;
+    }
+
+    private static Scenario getScenario(String scenarioName, Scenario[] scenarios) {
+        for (int i = 0; i < scenarios.length; i++) {
+            Scenario s = scenarios[i];
+            if (s.getScenarioName().equals(scenarioName)) {
+                return s;
+            }
+
+        }
+        return null;
+    }
+
+    /**
+     * Get all combinations of OS / JVM. This will be used for filtering.
+     *
+     * @return the JSON object containing all the combinations
+     * @throws JSONException
+     *             JSON error
+     */
+    private static JSONObject createOsJvm() throws JSONException {
+        JSONObject osjvm = new JSONObject();
+        List<String> oses = getDistinctOses();
+
+        int osJvmIndex = 1;
+        for (String os : oses) {
+            String key = JVM_LABEL;
+            Variations v = new Variations();
+
+            v.setProperty(BUILD_LABEL, WILDCARD_PATTERN);
+            v.setProperty(HOST_LABEL, WILDCARD_PATTERN);
+            v.setProperty(CONFIG_LABEL, os);
+            v.setProperty(JVM_LABEL, WILDCARD_PATTERN);
+
+            List<String> jvms = new ArrayList<>();
+            DB.queryDistinctValues(jvms, key, v, WILDCARD_PATTERN);
+            for (String jvm : jvms) {
+                JSONObject osjvmItem = new JSONObject();
+                osjvmItem.put(OS_LABEL, os);
+                osjvmItem.put(JVM_LABEL, jvm);
+                osjvmItem.put(DESCRIPTION_LABEL, os + " / " + jvm);
+                osjvm.put(Integer.toString(osJvmIndex), osjvmItem);
+                osJvmIndex++;
+            }
+        }
+
+        return osjvm;
+    }
+
+    /**
+     * Get all the distinct OS values
+     *
+     * @return the distinct OS values
+     */
+    private static List<String> getDistinctOses() {
+        List<String> configs = new ArrayList<>();
+        String key = PerformanceTestPlugin.CONFIG;
+        Variations v = new Variations();
+        v.setProperty(WILDCARD_PATTERN, WILDCARD_PATTERN);
+        DB.queryDistinctValues(configs, key, v, WILDCARD_PATTERN);
+        return configs;
+    }
+
+    /**
+     * This main can be run from within Eclipse provided everything is on the
+     * class path.
+     *
+     * @param args
+     *            the arguments
+     * @throws JSONException
+     *             JSON error
+     * @throws IOException
+     *             io error
+     */
+    public static void main(String[] args) throws JSONException, IOException {
+        new PerfResultsToJSon().parseResults();
+    }
+
+    /**
+     * Create a series of data points for a given scenario through variations
+     *
+     * @param scenario
+     *            the scenario. For example,
+     *            "CTF Read & Seek Benchmark (500 seeks)".
+     * @param variations
+     *            all variations to consider to create the series. For example
+     *            build=%;jvm=1.7;config=linux will generate the series for all
+     *            builds on Linux / JVM 1.7
+     * @param shortName
+     *            the short name of the scenario
+     * @param dimension
+     *            the dimension of interest (CPU time, used java heap, etc).
+     * @return the generated JSON object representing a series of data points
+     *         for this scenario
+     * @throws JSONException
+     */
+    private static JSONObject createSerie(Scenario scenario, Variations variations, String shortName, Dim dimension) throws JSONException {
+        JSONObject o = new JSONObject();
+        o.putOpt(KEY_LABEL, shortName);
+        o.putOpt(VALUES_LABEL, createDataPoints(scenario, variations, dimension));
+        return o;
+    }
+
+    /**
+     * Create data points for a given scenario and variations.
+     *
+     * @param s
+     *            the scenario. For example,
+     *            "CTF Read & Seek Benchmark (500 seeks)".
+     * @param variations
+     *            all variations to consider to create the data points. For
+     *            example build=%;jvm=1.7;config=linux will generate the data
+     *            points for all builds on Linux / JVM 1.7
+     * @param dimension
+     *            the dimension of interest (CPU time, used java heap, etc).
+     *
+     * @return the generated JSON array of points
+     * @throws JSONException
+     *             JSON error
+     */
+    private static JSONArray createDataPoints(Scenario s, Variations variations, Dim dimension) throws JSONException {
+        // Can be uncommented to see raw dump
+        //s.dump(System.out, PerformanceTestPlugin.BUILD);
+
+        String[] builds = DB.querySeriesValues(s.getScenarioName(), variations, PerformanceTestPlugin.BUILD);
+        Date[] dates = new Date[builds.length];
+        String[] commits = new String[builds.length];
+        for (int i = 0; i < builds.length; i++) {
+            dates[i] = parseBuildDate(builds[i]);
+            commits[i] = parseCommit(builds[i]);
+        }
+
+        TimeSeries timeSeries = s.getTimeSeries(dimension);
+        JSONArray dataPoints = new JSONArray();
+        int length = timeSeries.getLength();
+        for (int i = 0; i < length; i++) {
+            JSONObject point = new JSONObject();
+            if (dates[i] == null) {
+                continue;
+            }
+            point.put(X_LABEL, dates[i].getTime());
+            double value = 0;
+            if (timeSeries.getCount(i) > 0) {
+                value = timeSeries.getValue(i);
+                if (Double.isNaN(value)) {
+                    value = 0;
+                }
+            }
+            point.put(Y_LABEL, value);
+            dataPoints.put(point);
+            point.put(LABEL_LABEL, createLabel(commits[i]));
+        }
+        return dataPoints;
+    }
+
+    /**
+     * Create a label JSONObject which is used to attach more information to a
+     * data point.
+     *
+     * @param commit
+     *            the commit id for this data point
+     * @return the resulting JSON object
+     * @throws JSONException
+     *             JSON error
+     */
+    private static JSONObject createLabel(String commit) throws JSONException {
+        /*
+         * Here we could add more information about this specific data point
+         * like the commit author, the commit message, etc.
+         */
+        JSONObject label = new JSONObject();
+        if (commit != null && !commit.isEmpty()) {
+            label.put(COMMIT_LABEL, commit);
+        }
+        return label;
+    }
+
+    /**
+     * Get the commit id out of the build= string
+     *
+     * @param build
+     *            the build string
+     * @return the parsed commit id
+     */
+    private static String parseCommit(String build) {
+        Matcher matcher = COMMIT_PATTERN.matcher(build);
+        if (matcher.matches()) {
+            return matcher.group(1);
+        }
+        return null;
+    }
+
+    /**
+     * Get the Date out of the build= string
+     *
+     * @param build
+     *            the build string
+     * @return the parsed Date
+     */
+    private static Date parseBuildDate(String build) {
+        Matcher matcher = BUILD_DATE_PATTERN.matcher(build);
+        Date date = null;
+        if (matcher.matches()) {
+            String dateStr = matcher.group(1);
+            SimpleDateFormat f = new SimpleDateFormat(BUILD_DATE_FORMAT);
+            try {
+                date = dateStr.length() > BUILD_DATE_FORMAT.length() ?
+                        f.parse(dateStr.substring(dateStr.length() - BUILD_DATE_FORMAT.length())) :
+                        f.parse(dateStr);
+            } catch (ParseException e) {
+                return null;
+            }
+        }
+        return date;
+    }
+}
index 51136a2c9770f98636645ba43c9b1de08c443cc2..a515e81ccb11a1a47442dcefccc269df3c8267a7 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="lttng-e3.8" sequenceNumber="27">
+<?pde version="3.8"?><target name="lttng-e3.8" sequenceNumber="28">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.antlr.runtime" version="3.2.0.v201101311130"/>
@@ -8,6 +8,7 @@
 <unit id="org.swtchart" version="0.0.0"/>
 <unit id="com.google.guava" version="15.0.0.v201403281430"/>
 <unit id="org.apache.derby" version="0.0.0"/>
+<unit id="org.json" version="0.0.0"/>
 <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20140525021250/repository/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
index 1dc9e1e4b6dbe64f1ce952811b22ad555738ec5d..dfbbfd19d06b14287a4fbe054fd578c70cd512ea 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="lttng-e4.2" sequenceNumber="27">
+<?pde version="3.8"?><target name="lttng-e4.2" sequenceNumber="28">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.antlr.runtime" version="3.2.0.v201101311130"/>
@@ -8,6 +8,7 @@
 <unit id="org.swtchart" version="0.0.0"/>
 <unit id="com.google.guava" version="15.0.0.v201403281430"/>
 <unit id="org.apache.derby" version="0.0.0"/>
+<unit id="org.json" version="0.0.0"/>
 <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20140525021250/repository/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
index f77874a9d3d21a196ff12b7e6844208aeccd3b40..f68a09dd2526fc692c529b4659a61221e985b330 100644 (file)
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="lttng-e4.3" sequenceNumber="27">
+<?pde version="3.8"?><target name="lttng-e4.3" sequenceNumber="28">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.antlr.runtime" version="3.2.0.v201101311130"/>
 <unit id="org.swtchart" version="0.0.0"/>
 <unit id="com.google.guava" version="15.0.0.v201403281430"/>
 <unit id="org.apache.derby" version="0.0.0"/>
+<unit id="org.json" version="0.0.0"/>
 <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20140525021250/repository/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
index bdeadbb535d5bf7fe618fa84d8b3c8df06a1b3a8..95d21e84bb659ba9d9f3252e79a8e2ad7a3db96e 100644 (file)
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="lttng-e4.4" sequenceNumber="27">
+<?pde version="3.8"?><target name="lttng-e4.4" sequenceNumber="28">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.antlr.runtime" version="3.2.0.v201101311130"/>
 <unit id="org.swtchart" version="0.0.0"/>
 <unit id="com.google.guava" version="15.0.0.v201403281430"/>
 <unit id="org.apache.derby" version="0.0.0"/>
+<unit id="org.json" version="0.0.0"/>
 <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20140525021250/repository/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
index a3a09233d528a7c11c1c2cee7fe1067b9e97b4eb..a50dd1941e6ff2c5f1cb8cc831b5cbfe012fcd0a 100644 (file)
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="lttng-eStaging" sequenceNumber="26">
+<?pde version="3.8"?><target name="lttng-eStaging" sequenceNumber="28">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.antlr.runtime" version="3.2.0.v201101311130"/>
 <unit id="org.swtchart" version="0.0.0"/>
 <unit id="com.google.guava" version="15.0.0.v201403281430"/>
 <unit id="org.apache.derby" version="0.0.0"/>
+<unit id="org.json" version="0.0.0"/>
 <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20140525021250/repository/"/>
 </location>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
diff --git a/pom.xml b/pom.xml
index ff5d613ae2418aeb99815ab6029941e993258f74..b42315bc9c8140c4403d665d5760b4283fe40300 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <module>org.eclipse.linuxtools.lttng.releng-site</module>
       </modules>
   </profile>
+  <profile>
+    <id>performance</id>
+    <modules>
+      <module>org.eclipse.linuxtools.lttng.alltests</module>
+    </modules>
+  </profile>
   <profile>
     <id>macosx</id>
     <activation>
This page took 0.059067 seconds and 5 git commands to generate.