1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 * Alexandre Montplaisir - Convert to org.eclipse.test.performance test
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.tests
.perf
.analysis
.kernel
;
16 import static org
.junit
.Assert
.fail
;
19 import java
.util
.Arrays
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
22 import org
.eclipse
.test
.performance
.Dimension
;
23 import org
.eclipse
.test
.performance
.Performance
;
24 import org
.eclipse
.test
.performance
.PerformanceMeter
;
25 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernel
.KernelAnalysisModule
;
26 import org
.eclipse
.tracecompass
.lttng2
.kernel
.core
.trace
.LttngKernelTrace
;
27 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.IAnalysisModule
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfTraceException
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.tests
.shared
.TmfTestHelper
;
32 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
33 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEvent
;
34 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTraceUtils
;
35 import org
.junit
.Test
;
36 import org
.junit
.runner
.RunWith
;
37 import org
.junit
.runners
.Parameterized
;
38 import org
.junit
.runners
.Parameterized
.Parameters
;
41 * This is a test of the time to build a kernel state system
43 * @author Genevieve Bastien
45 @RunWith(Parameterized
.class)
46 public class KernelAnalysisBenchmark
{
48 private static final String TEST_ID
= "org.eclipse.linuxtools#LTTng kernel analysis#";
49 private static final int LOOP_COUNT
= 25;
51 private final TestModule fTestModule
;
53 private enum TestModule
{
56 NULL_BACKEND("(Data not saved to disk)");
58 private final String fName
;
60 private TestModule(String name
) {
64 public String
getTestNameString() {
68 public static IAnalysisModule
getNewModule(TestModule moduleType
) {
70 case NORMAL_EXECUTION
:
71 return new KernelAnalysisModule();
73 return new KernelAnalysisModuleNullBeStub();
75 throw new IllegalStateException();
84 * A name for the test, to display in the header
86 * A test case parameter for this test
88 public KernelAnalysisBenchmark(String testName
, TestModule module
) {
93 * @return The arrays of parameters
95 @Parameters(name
= "{index}: {0}")
96 public static Iterable
<Object
[]> getParameters() {
97 return Arrays
.asList(new Object
[][] {
98 { TestModule
.NORMAL_EXECUTION
.name(), TestModule
.NORMAL_EXECUTION
},
99 { TestModule
.NULL_BACKEND
.name(), TestModule
.NULL_BACKEND
}
104 * Run the benchmark with "trace2"
107 public void testTrace2() {
108 runTest(CtfTestTrace
.TRACE2
, "Trace2", fTestModule
);
111 private static void runTest(@NonNull CtfTestTrace testTrace
, String testName
, TestModule testModule
) {
112 Performance perf
= Performance
.getDefault();
113 PerformanceMeter pm
= perf
.createPerformanceMeter(TEST_ID
+ testName
+ testModule
.getTestNameString());
114 perf
.tagAsSummary(pm
, "LTTng Kernel Analysis: " + testName
+ testModule
.getTestNameString(), Dimension
.CPU_TIME
);
116 if ((testTrace
== CtfTestTrace
.TRACE2
) && (testModule
== TestModule
.NORMAL_EXECUTION
)) {
117 /* Do not show all traces in the global summary */
118 perf
.tagAsGlobalSummary(pm
, "LTTng Kernel Analysis" + testModule
.getTestNameString() + ": " + testName
, Dimension
.CPU_TIME
);
121 for (int i
= 0; i
< LOOP_COUNT
; i
++) {
122 LttngKernelTrace trace
= null;
123 IAnalysisModule module
= null;
124 // TODO Allow the utility method to instantiate trace sub-types
126 String path
= CtfTmfTestTraceUtils
.getTrace(testTrace
).getPath();
129 trace
= new LttngKernelTrace();
130 module
= TestModule
.getNewModule(testModule
);
131 module
.setId("test");
132 trace
.initTrace(null, path
, CtfTmfEvent
.class);
133 module
.setTrace(trace
);
136 TmfTestHelper
.executeAnalysis(module
);
140 * Delete the supplementary files, so that the next iteration
141 * rebuilds the state system.
143 File suppDir
= new File(TmfTraceManager
.getSupplementaryFileDir(trace
));
144 for (File file
: suppDir
.listFiles()) {
148 } catch (TmfAnalysisException
| TmfTraceException e
) {
149 fail(e
.getMessage());
151 if (module
!= null) {
160 CtfTmfTestTraceUtils
.dispose(testTrace
);
This page took 0.038466 seconds and 5 git commands to generate.