From e34d62dc481d451c1ed4ab4fff79ed31038adca2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Thu, 18 Feb 2016 11:51:50 -0500 Subject: [PATCH] analysis: use a null backend for the kernel analysis benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- .../META-INF/MANIFEST.MF | 1 + .../KernelAnalysisBenchmark.java} | 77 ++++++++++++++++--- .../KernelAnalysisModuleNullBeStub.java | 29 +++++++ .../alltests/perf/RunAllPerfTests.java | 2 +- 4 files changed, 98 insertions(+), 11 deletions(-) rename lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/{AnalysisBenchmark.java => kernel/KernelAnalysisBenchmark.java} (62%) create mode 100644 lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisModuleNullBeStub.java 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/kernel/KernelAnalysisBenchmark.java similarity index 62% rename from lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/AnalysisBenchmark.java rename to lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/kernel/KernelAnalysisBenchmark.java index af1da77c22..1e2946b02f 100644 --- 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/kernel/KernelAnalysisBenchmark.java @@ -11,11 +11,12 @@ * Alexandre Montplaisir - Convert to org.eclipse.test.performance test *******************************************************************************/ -package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis; +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; @@ -32,33 +33,89 @@ 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 */ -public class AnalysisBenchmark { +@RunWith(Parameterized.class) +public class KernelAnalysisBenchmark { - private static final String TEST_ID = "org.eclipse.linuxtools#LTTng kernel analysis"; + 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"); + runTest(CtfTestTrace.TRACE2, "Trace2", fTestModule); } - private static void runTest(@NonNull CtfTestTrace testTrace, String testName) { + private static void runTest(@NonNull CtfTestTrace testTrace, String testName, TestModule testModule) { Performance perf = Performance.getDefault(); - PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); - perf.tagAsSummary(pm, "LTTng Kernel Analysis: " + testName, Dimension.CPU_TIME); + 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) { + if ((testTrace == CtfTestTrace.TRACE2) && (testModule == TestModule.NORMAL_EXECUTION)) { /* Do not show all traces in the global summary */ - perf.tagAsGlobalSummary(pm, "LTTng Kernel Analysis: " + testName, Dimension.CPU_TIME); + perf.tagAsGlobalSummary(pm, "LTTng Kernel Analysis" + testModule.getTestNameString() + ": " + testName, Dimension.CPU_TIME); } for (int i = 0; i < LOOP_COUNT; i++) { @@ -70,7 +127,7 @@ public class AnalysisBenchmark { try { trace = new LttngKernelTrace(); - module = new KernelAnalysisModule(); + module = TestModule.getNewModule(testModule); module.setId("test"); trace.initTrace(null, path, CtfTmfEvent.class); module.setTrace(trace); 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, -- 2.34.1