analysis: use a null backend for the kernel analysis benchmark
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Thu, 18 Feb 2016 16:51:50 +0000 (11:51 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 25 Feb 2016 01:43:24 +0000 (20:43 -0500)
This adds a benchmark that does not save the state system to disk. It
allows to benchmark only the analysis (and the reading of the events).

Change-Id: I271064111a4c55cf3010c66b3c9c6998d2444a27
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/66853
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/AnalysisBenchmark.java [deleted file]
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisBenchmark.java [new file with mode: 0644]
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisModuleNullBeStub.java [new file with mode: 0644]
releng/org.eclipse.tracecompass.alltests/src/org/eclipse/tracecompass/alltests/perf/RunAllPerfTests.java

index 7e0df50c5dcf3cde6184fbc53e59761778d04d87..71a75562ce45300eb253c87816ded0b150604e24 100644 (file)
@@ -26,6 +26,7 @@ Export-Package: org.eclipse.tracecompass.lttng2.kernel.core.tests,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.kernel.statesystem;x-internal:=true,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.event.matchandsync;x-internal:=true,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis,
+ org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.event.matching,
  org.eclipse.tracecompass.lttng2.lttng.kernel.core.tests.shared.vm
 Import-Package: com.google.common.collect,
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/AnalysisBenchmark.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/AnalysisBenchmark.java
deleted file mode 100644 (file)
index af1da77..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 É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
- *   Alexandre Montplaisir - Convert to org.eclipse.test.performance test
- *******************************************************************************/
-
-package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis;
-
-import static org.junit.Assert.fail;
-
-import java.io.File;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.test.performance.Dimension;
-import org.eclipse.test.performance.Performance;
-import org.eclipse.test.performance.PerformanceMeter;
-import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
-import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
-import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
-import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
-import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestHelper;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
-import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
-import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
-import org.junit.Test;
-
-/**
- * This is a test of the time to build a kernel state system
- *
- * @author Genevieve Bastien
- */
-public class AnalysisBenchmark {
-
-    private static final String TEST_ID = "org.eclipse.linuxtools#LTTng kernel analysis";
-    private static final int LOOP_COUNT = 25;
-
-    /**
-     * Run the benchmark with "trace2"
-     */
-    @Test
-    public void testTrace2() {
-        runTest(CtfTestTrace.TRACE2, "Trace2");
-    }
-
-    private static void runTest(@NonNull CtfTestTrace testTrace, String testName) {
-        Performance perf = Performance.getDefault();
-        PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName);
-        perf.tagAsSummary(pm, "LTTng Kernel Analysis: " + testName, Dimension.CPU_TIME);
-
-        if (testTrace == CtfTestTrace.TRACE2) {
-            /* Do not show all traces in the global summary */
-            perf.tagAsGlobalSummary(pm, "LTTng Kernel Analysis: " + testName, Dimension.CPU_TIME);
-        }
-
-        for (int i = 0; i < LOOP_COUNT; i++) {
-            LttngKernelTrace trace = null;
-            IAnalysisModule module = null;
-            // TODO Allow the utility method to instantiate trace sub-types
-            // directly.
-            String path = CtfTmfTestTraceUtils.getTrace(testTrace).getPath();
-
-            try {
-                trace = new LttngKernelTrace();
-                module = new KernelAnalysisModule();
-                module.setId("test");
-                trace.initTrace(null, path, CtfTmfEvent.class);
-                module.setTrace(trace);
-
-                pm.start();
-                TmfTestHelper.executeAnalysis(module);
-                pm.stop();
-
-                /*
-                 * Delete the supplementary files, so that the next iteration
-                 * rebuilds the state system.
-                 */
-                File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(trace));
-                for (File file : suppDir.listFiles()) {
-                    file.delete();
-                }
-
-            } catch (TmfAnalysisException | TmfTraceException e) {
-                fail(e.getMessage());
-            } finally {
-                if (module != null) {
-                    module.dispose();
-                }
-                if (trace != null) {
-                    trace.dispose();
-                }
-            }
-        }
-        pm.commit();
-        CtfTmfTestTraceUtils.dispose(testTrace);
-    }
-}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisBenchmark.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisBenchmark.java
new file mode 100644 (file)
index 0000000..1e2946b
--- /dev/null
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 2015 É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
+ *   Alexandre Montplaisir - Convert to org.eclipse.test.performance test
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.Arrays;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
+import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestHelper;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * This is a test of the time to build a kernel state system
+ *
+ * @author Genevieve Bastien
+ */
+@RunWith(Parameterized.class)
+public class KernelAnalysisBenchmark {
+
+    private static final String TEST_ID = "org.eclipse.linuxtools#LTTng kernel analysis#";
+    private static final int LOOP_COUNT = 25;
+
+    private final TestModule fTestModule;
+
+    private enum TestModule {
+
+        NORMAL_EXECUTION(""),
+        NULL_BACKEND("(Data not saved to disk)");
+
+        private final String fName;
+
+        private TestModule(String name) {
+            fName = name;
+        }
+
+        public String getTestNameString() {
+            return fName;
+        }
+
+        public static IAnalysisModule getNewModule(TestModule moduleType) {
+            switch (moduleType) {
+            case NORMAL_EXECUTION:
+                return new KernelAnalysisModule();
+            case NULL_BACKEND:
+                return new KernelAnalysisModuleNullBeStub();
+            default:
+                throw new IllegalStateException();
+            }
+        }
+    }
+
+    /**
+     * Constructor
+     *
+     * @param testName
+     *            A name for the test, to display in the header
+     * @param module
+     *            A test case parameter for this test
+     */
+    public KernelAnalysisBenchmark(String testName, TestModule module) {
+        fTestModule = module;
+    }
+
+    /**
+     * @return The arrays of parameters
+     */
+    @Parameters(name = "{index}: {0}")
+    public static Iterable<Object[]> getParameters() {
+        return Arrays.asList(new Object[][] {
+                { TestModule.NORMAL_EXECUTION.name(), TestModule.NORMAL_EXECUTION },
+                { TestModule.NULL_BACKEND.name(), TestModule.NULL_BACKEND }
+        });
+    }
+
+    /**
+     * Run the benchmark with "trace2"
+     */
+    @Test
+    public void testTrace2() {
+        runTest(CtfTestTrace.TRACE2, "Trace2", fTestModule);
+    }
+
+    private static void runTest(@NonNull CtfTestTrace testTrace, String testName, TestModule testModule) {
+        Performance perf = Performance.getDefault();
+        PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + testModule.getTestNameString());
+        perf.tagAsSummary(pm, "LTTng Kernel Analysis: " + testName + testModule.getTestNameString(), Dimension.CPU_TIME);
+
+        if ((testTrace == CtfTestTrace.TRACE2) && (testModule == TestModule.NORMAL_EXECUTION)) {
+            /* Do not show all traces in the global summary */
+            perf.tagAsGlobalSummary(pm, "LTTng Kernel Analysis" + testModule.getTestNameString() + ": " + testName, Dimension.CPU_TIME);
+        }
+
+        for (int i = 0; i < LOOP_COUNT; i++) {
+            LttngKernelTrace trace = null;
+            IAnalysisModule module = null;
+            // TODO Allow the utility method to instantiate trace sub-types
+            // directly.
+            String path = CtfTmfTestTraceUtils.getTrace(testTrace).getPath();
+
+            try {
+                trace = new LttngKernelTrace();
+                module = TestModule.getNewModule(testModule);
+                module.setId("test");
+                trace.initTrace(null, path, CtfTmfEvent.class);
+                module.setTrace(trace);
+
+                pm.start();
+                TmfTestHelper.executeAnalysis(module);
+                pm.stop();
+
+                /*
+                 * Delete the supplementary files, so that the next iteration
+                 * rebuilds the state system.
+                 */
+                File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(trace));
+                for (File file : suppDir.listFiles()) {
+                    file.delete();
+                }
+
+            } catch (TmfAnalysisException | TmfTraceException e) {
+                fail(e.getMessage());
+            } finally {
+                if (module != null) {
+                    module.dispose();
+                }
+                if (trace != null) {
+                    trace.dispose();
+                }
+            }
+        }
+        pm.commit();
+        CtfTmfTestTraceUtils.dispose(testTrace);
+    }
+}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisModuleNullBeStub.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisModuleNullBeStub.java
new file mode 100644 (file)
index 0000000..3334828
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2016 É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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
+
+/**
+ * This class is an extension of {@link KernelAnalysisModule} that uses a null
+ * backend instead of the default one. This allows to benchmark this analysis
+ * without benchmarking the insertions in the state system.
+ *
+ * @author Geneviève Bastien
+ */
+public class KernelAnalysisModuleNullBeStub extends KernelAnalysisModule {
+
+    @Override
+    protected @NonNull StateSystemBackendType getBackendType() {
+        return StateSystemBackendType.NULL;
+    }
+
+}
index 2684173412b071cb68422f048f44f6bab3f2916a..bd4561d7361c10fbb8141838d8da417360ce14a6 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.runners.Suite;
     org.eclipse.tracecompass.ctf.core.tests.perf.trace.TraceReadBenchmark.class,
     org.eclipse.tracecompass.ctf.core.tests.perf.trace.TraceSeekBenchmark.class,
 
-    org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.AnalysisBenchmark.class,
+    org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel.KernelAnalysisBenchmark.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.StatisticsAnalysisBenchmark.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.event.matching.EventMatchingBenchmark.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.event.matching.TraceSynchronizationBenchmark.class,
This page took 0.030132 seconds and 5 git commands to generate.