tmf: Introduce performance tests to TMF
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Mon, 9 Jun 2014 19:33:28 +0000 (15:33 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 27 Jun 2014 01:32:02 +0000 (21:32 -0400)
Add separate source directories in test packages specifically for
performance tests based on org.eclipse.test.performance.

Change-Id: Ia28d5269a6ba81f0727eb2a65858c97566dbf1d9
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/28282
Tested-by: Hudson CI
org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ctf.core.tests/.classpath
org.eclipse.linuxtools.tmf.ctf.core.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.ctf.core.tests/build.properties
org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/AllPerfTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/AllPerfTests.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/ExperimentBenchmark.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/headless/ExperimentBenchmark.java [deleted file]

diff --git a/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java b/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java
new file mode 100644 (file)
index 0000000..1fa5099
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.alltests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Master test suite for all Linux Tools LTTng performance tests.
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    org.eclipse.linuxtools.tmf.ctf.core.tests.perf.AllPerfTests.class
+})
+public class RunAllPerfTests {
+
+}
index 68143fe727862b3db96a1577af9d6e9ca10c0a9b..11921cabe43a9f6bef6db1b91783289068975825 100644 (file)
@@ -3,6 +3,7 @@
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
        <classpathentry kind="src" path="src"/>
+       <classpathentry kind="src" path="perf"/>
        <classpathentry kind="src" path="shared"/>
        <classpathentry kind="src" path="stubs"/>
        <classpathentry kind="output" path="bin"/>
        <classpathentry kind="src" path="shared"/>
        <classpathentry kind="src" path="stubs"/>
        <classpathentry kind="output" path="bin"/>
index 6f9c9e50c1985d0fde5921edb4b0cf77f69f6e7d..a17b351b6acd868f265d66748488932ef7aa2c82 100644 (file)
@@ -17,8 +17,11 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.linuxtools.ctf.core.tests
 Export-Package: org.eclipse.linuxtools.tmf.ctf.core.tests,
  org.eclipse.linuxtools.tmf.ctf.core.tests.headless;x-internal:=true,
  org.eclipse.linuxtools.ctf.core.tests
 Export-Package: org.eclipse.linuxtools.tmf.ctf.core.tests,
  org.eclipse.linuxtools.tmf.ctf.core.tests.headless;x-internal:=true,
+ org.eclipse.linuxtools.tmf.ctf.core.tests.perf,
+ org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment;x-internal:=true,
  org.eclipse.linuxtools.tmf.ctf.core.tests.request;x-internal:=true,
  org.eclipse.linuxtools.tmf.ctf.core.tests.shared,
  org.eclipse.linuxtools.tmf.ctf.core.tests.statistics;x-internal:=true,
  org.eclipse.linuxtools.tmf.ctf.core.tests.stubs,
  org.eclipse.linuxtools.tmf.ctf.core.tests.tracemanager;x-internal:=true
  org.eclipse.linuxtools.tmf.ctf.core.tests.request;x-internal:=true,
  org.eclipse.linuxtools.tmf.ctf.core.tests.shared,
  org.eclipse.linuxtools.tmf.ctf.core.tests.statistics;x-internal:=true,
  org.eclipse.linuxtools.tmf.ctf.core.tests.stubs,
  org.eclipse.linuxtools.tmf.ctf.core.tests.tracemanager;x-internal:=true
+Import-Package: org.eclipse.test.performance
index 9f2d161159fc4c43a0d52d6eaf90149a43cb777b..2f7d89bee198c95f58a9d736dd42c0e6352def2e 100644 (file)
@@ -11,6 +11,7 @@
 ###############################################################################
 
 source.. = src/,\
 ###############################################################################
 
 source.. = src/,\
+           perf/,\
            shared/,\
            stubs
 output.. = bin/
            shared/,\
            stubs
 output.. = bin/
diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/AllPerfTests.java b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/AllPerfTests.java
new file mode 100644 (file)
index 0000000..630b212
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ctf.core.tests.perf;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * The class <code>AllPerformanceTests</code> builds a suite that can be used to
+ * run all of the performance tests within its package as well as within any
+ * subpackages of its package.
+ *
+ * @author Geneviève Bastien
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+        org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment.AllPerfTests.class
+})
+public class AllPerfTests {
+
+}
diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/AllPerfTests.java b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/AllPerfTests.java
new file mode 100644 (file)
index 0000000..c7727ea
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2014 École Polytechnique de Montréal
+ *
+ * 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:
+ *   Geneviève Bastien - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+        ExperimentBenchmark.class
+})
+public class AllPerfTests {
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/ExperimentBenchmark.java b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/ExperimentBenchmark.java
new file mode 100644 (file)
index 0000000..5c038b3
--- /dev/null
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * 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:
+ *     Matthew Khouzam - Initial API and implementation
+ *     Geneviève Bastien - Convert to JUnit performance test
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
+import org.junit.Test;
+
+/**
+ * Coalescing benchmark
+ *
+ * @author Matthew Khouzam
+ */
+public class ExperimentBenchmark {
+
+    private static final String TEST_ID = "org.eclipse.linuxtools#Experiment benchmark";
+    private static final int MAX_TRACES = 160;
+    private static final int BLOCK_SIZE = 100;
+    private static final String TRACES_ROOT_PATH = CtfTestTrace.TRACE_EXPERIMENT.getPath();
+    private static final int SAMPLE_SIZE = 5;
+
+    private TmfExperimentStub fExperiment;
+
+    /**
+     * Run the benchmark
+     */
+    @Test
+    public void benchmarkExperimentSizeRequest() {
+        Performance perf = Performance.getDefault();
+
+        for (int numTraces = 1; numTraces < MAX_TRACES; numTraces = (int) (1.6 * (numTraces + 1))) {
+            PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '(' + numTraces + ')');
+            perf.tagAsSummary(pm, "Experiment Benchmark traces:" + numTraces, Dimension.CPU_TIME);
+            if ((int) (1.6 * (numTraces + 1)) > MAX_TRACES) {
+                perf.tagAsGlobalSummary(pm, "Experiment Benchmark traces: " + numTraces, Dimension.CPU_TIME);
+            }
+
+            for (int s = 0; s < SAMPLE_SIZE; s++) {
+
+                InnerEventRequest expReq = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
+                InnerEventRequest traceReq[] = new InnerEventRequest[numTraces];
+
+                init(numTraces);
+                fExperiment.sendRequest(expReq);
+                ITmfTrace[] traces = fExperiment.getTraces();
+                for (int i = 0; i < numTraces; i++) {
+                    traceReq[i] = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
+                    traces[i].sendRequest(traceReq[i]);
+                }
+
+                pm.start();
+                waitForRequest(expReq, traceReq);
+                pm.stop();
+
+                for (int i = 0; i < traces.length; i++) {
+                    if (!expReq.isTraceHandled(traces[i])) {
+                        System.err.println("Trace " + i + " not handled!");
+                    }
+                }
+
+                fExperiment.dispose();
+            }
+            pm.commit();
+        }
+    }
+
+    /**
+     * Initialization
+     *
+     * @param maxTraces
+     *            maximum number of traces to open
+     */
+    private void init(int maxTraces) {
+        try {
+            File parentDir = new File(TRACES_ROOT_PATH);
+            File[] traceFiles = parentDir.listFiles();
+            ITmfTrace[] traces = new CtfTmfTrace[Math.min(maxTraces, traceFiles.length)];
+            for (int i = 0; i < traces.length; i++) {
+                traces[i] = new CtfTmfTrace();
+            }
+            fExperiment = new TmfExperimentStub("MegaExperiment", traces, BLOCK_SIZE);
+            int j = 0;
+            for (int i = 0; i < (traces.length) && (j < traces.length); i++) {
+                String absolutePath = traceFiles[j].getAbsolutePath();
+                if (traces[i].validate(null, absolutePath).isOK()) {
+                    traces[i].initTrace(null, absolutePath, ITmfEvent.class);
+                } else {
+                    i--;
+                }
+                j++;
+            }
+            if (traces[traces.length - 1].getPath() == null) {
+                throw new TmfTraceException("Insufficient valid traces in directory");
+            }
+        } catch (TmfTraceException e) {
+            System.out.println(e.getMessage());
+        }
+    }
+
+    private static void waitForRequest(InnerEventRequest expReq, InnerEventRequest[] traceReqs) {
+        try {
+            expReq.waitForCompletion();
+            List<InnerEventRequest> reqs = Arrays.asList(traceReqs);
+            for (InnerEventRequest traceReq : reqs) {
+                traceReq.waitForCompletion();
+            }
+        } catch (InterruptedException e) {
+        }
+    }
+
+    private static class InnerEventRequest extends TmfEventRequest {
+        private Set<String> fTraces = new HashSet<>();
+
+        public InnerEventRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, ExecutionType priority) {
+            super(dataType, index, nbRequested, priority);
+        }
+
+        @Override
+        public void handleData(ITmfEvent event) {
+            super.handleData(event);
+            if (!fTraces.contains(event.getTrace().getName())) {
+                fTraces.add(event.getTrace().getName());
+            }
+        }
+
+        public boolean isTraceHandled(ITmfTrace trace) {
+            return fTraces.contains(trace.getName());
+        }
+    }
+}
diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/headless/ExperimentBenchmark.java b/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/headless/ExperimentBenchmark.java
deleted file mode 100644 (file)
index a5f8ceb..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * 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:
- *     Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ctf.core.tests.headless;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub;
-
-/**
- * Coalescing benchmark
- *
- * @author Matthew Khouzam
- *
- */
-public class ExperimentBenchmark {
-    private static final int MAX_TRACES = 160;
-    private static final int BLOCK_SIZE = 100;
-    private static final String TRACES_ROOT_PATH = CtfTestTrace.TRACE_EXPERIMENT.getPath();
-    private ITmfTrace[] traces;
-    private TmfExperimentStub fExperiment;
-
-    /**
-     * initialization
-     *
-     * @param maxTraces
-     *            maximum number of traces to open
-     *
-     * @throws TmfTraceException
-     *             problem
-     */
-    private void init(int maxTraces) throws TmfTraceException {
-        File parentDir = new File(TRACES_ROOT_PATH);
-        File[] traceFiles = parentDir.listFiles();
-        traces = new CtfTmfTrace[Math.min(maxTraces, traceFiles.length)];
-        for (int i = 0; i < traces.length; i++) {
-            traces[i] = new CtfTmfTrace();
-        }
-        fExperiment = new TmfExperimentStub("MegaExperiment", traces, BLOCK_SIZE);
-        int j = 0;
-        for (int i = 0; i < (traces.length) && (j < traces.length); i++) {
-            String absolutePath = traceFiles[j].getAbsolutePath();
-            if (traces[i].validate(null, absolutePath).isOK()) {
-                traces[i].initTrace(null, absolutePath, ITmfEvent.class);
-            } else {
-                i--;
-            }
-            j++;
-        }
-        if (traces[traces.length - 1].getPath() == null) {
-            throw new TmfTraceException("Insufficient valid traces in directory");
-        }
-
-    }
-
-    /**
-     * Main benchmark
-     *
-     * @param args
-     *            benchmark
-     */
-    public static void main(final String[] args) {
-        ExperimentBenchmark eb = new ExperimentBenchmark();
-        eb.testRun();
-
-    }
-
-    /**
-     * Run the benchmark
-     */
-    public void testRun() {
-        System.out.println("Test, init, request, dispose");
-
-        for (int numTraces = 1; numTraces < MAX_TRACES; numTraces = (int) (1.1 * (numTraces + 1))) {
-            InnerEventRequest expReq = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
-
-            InnerEventRequest traceReq[] = new InnerEventRequest[numTraces];
-
-            System.out.print(numTraces);
-
-            waitForInit(numTraces);
-            fExperiment.sendRequest(expReq);
-            for (int i = 0; i < numTraces; i++) {
-                traceReq[i] = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
-                traces[i].sendRequest(traceReq[i]);
-            }
-            waitForRequest(expReq, traceReq);
-
-            for (int i = 0; i < traces.length; i++) {
-                if (!expReq.isTraceHandled(traces[i])) {
-                    System.err.println("Trace " + i + " not handled!");
-                }
-            }
-            waitForDispose();
-            System.out.println("");
-        }
-    }
-
-    private void waitForDispose() {
-        long start = System.nanoTime();
-        fExperiment.dispose();
-        for (int i = 0; i < traces.length; i++) {
-            traces[i].dispose();
-        }
-        long end = System.nanoTime();
-        printTime(start, end);
-    }
-
-    private void waitForInit(int numTraces) {
-        long start = System.nanoTime();
-        try {
-            init(numTraces);
-        } catch (TmfTraceException e) {
-            System.out.println(e.getMessage());
-        }
-        long end = System.nanoTime();
-        printTime(start, end);
-    }
-
-    private static void waitForRequest(InnerEventRequest expReq, InnerEventRequest[] traceReqs) {
-        long start = System.nanoTime();
-        try {
-            expReq.waitForCompletion();
-            List<InnerEventRequest> reqs = Arrays.asList(traceReqs);
-            for (InnerEventRequest traceReq : reqs) {
-                traceReq.waitForCompletion();
-            }
-        } catch (InterruptedException e) {
-        }
-        long end = System.nanoTime();
-        printTime(start, end);
-    }
-
-    private static void printTime(long start, long end) {
-        /* print out the difference between the two nanosecond times in ms */
-        System.out.format(", %.3f", 0.000000001 * (end - start));
-    }
-
-    private static class InnerEventRequest extends TmfEventRequest {
-        private Set<String> fTraces = new HashSet<>();
-
-        public InnerEventRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, ExecutionType priority) {
-            super(dataType, index, nbRequested, priority);
-        }
-
-        @Override
-        public void handleData(ITmfEvent event) {
-            super.handleData(event);
-            if (!fTraces.contains(event.getTrace().getName())) {
-                fTraces.add(event.getTrace().getName());
-            }
-        }
-
-        public boolean isTraceHandled(ITmfTrace trace) {
-            return fTraces.contains(trace.getName());
-        }
-    }
-}
This page took 0.045022 seconds and 5 git commands to generate.