From: Geneviève Bastien Date: Thu, 18 Feb 2016 16:51:50 +0000 (-0500) Subject: analysis: use a null backend for the kernel analysis benchmark X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;ds=sidebyside;h=e34d62dc481d451c1ed4ab4fff79ed31038adca2;p=deliverable%2Ftracecompass.git analysis: use a null backend for the kernel analysis benchmark 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 Reviewed-on: https://git.eclipse.org/r/66853 Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam Reviewed-by: Hudson CI --- diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF index 7e0df50c5d..71a75562ce 100644 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF @@ -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 index af1da77c22..0000000000 --- a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/AnalysisBenchmark.java +++ /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 index 0000000000..1e2946b02f --- /dev/null +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisBenchmark.java @@ -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 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 index 0000000000..3334828ecd --- /dev/null +++ b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisModuleNullBeStub.java @@ -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; + } + +} diff --git a/releng/org.eclipse.tracecompass.alltests/src/org/eclipse/tracecompass/alltests/perf/RunAllPerfTests.java b/releng/org.eclipse.tracecompass.alltests/src/org/eclipse/tracecompass/alltests/perf/RunAllPerfTests.java index 2684173412..bd4561d736 100644 --- a/releng/org.eclipse.tracecompass.alltests/src/org/eclipse/tracecompass/alltests/perf/RunAllPerfTests.java +++ b/releng/org.eclipse.tracecompass.alltests/src/org/eclipse/tracecompass/alltests/perf/RunAllPerfTests.java @@ -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,