3b45e94cda728efb16f5e970ef3f97e69c654061
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
{
49 * Test test ID for kernel analysis benchmarks
51 public static final String TEST_ID
= "org.eclipse.linuxtools#LTTng kernel analysis#";
52 private static final int LOOP_COUNT
= 25;
54 private final TestModule fTestModule
;
56 private enum TestModule
{
59 NULL_BACKEND("(Data not saved to disk)");
61 private final String fName
;
63 private TestModule(String name
) {
67 public String
getTestNameString() {
71 public static IAnalysisModule
getNewModule(TestModule moduleType
) {
73 case NORMAL_EXECUTION
:
74 return new KernelAnalysisModule();
76 return new KernelAnalysisModuleNullBeStub();
78 throw new IllegalStateException();
87 * A name for the test, to display in the header
89 * A test case parameter for this test
91 public KernelAnalysisBenchmark(String testName
, TestModule module
) {
96 * @return The arrays of parameters
98 @Parameters(name
= "{index}: {0}")
99 public static Iterable
<Object
[]> getParameters() {
100 return Arrays
.asList(new Object
[][] {
101 { TestModule
.NORMAL_EXECUTION
.name(), TestModule
.NORMAL_EXECUTION
},
102 { TestModule
.NULL_BACKEND
.name(), TestModule
.NULL_BACKEND
}
107 * Run the benchmark with "trace2"
110 public void testTrace2() {
111 runTest(CtfTestTrace
.TRACE2
, "Trace2", fTestModule
);
115 * Run the benchmark with "many thread"
118 public void testManyThreads() {
119 runTest(CtfTestTrace
.MANY_THREADS
, "Many Threads", fTestModule
);
123 * Run the benchmark with "django httpd"
126 public void testDjangoHttpd() {
127 runTest(CtfTestTrace
.DJANGO_HTTPD
, "Django httpd", fTestModule
);
130 private static void runTest(@NonNull CtfTestTrace testTrace
, String testName
, TestModule testModule
) {
131 Performance perf
= Performance
.getDefault();
132 PerformanceMeter pm
= perf
.createPerformanceMeter(TEST_ID
+ testName
+ testModule
.getTestNameString());
133 perf
.tagAsSummary(pm
, "LTTng Kernel Analysis: " + testName
+ testModule
.getTestNameString(), Dimension
.CPU_TIME
);
135 if ((testTrace
== CtfTestTrace
.TRACE2
) && (testModule
== TestModule
.NORMAL_EXECUTION
)) {
136 /* Do not show all traces in the global summary */
137 perf
.tagAsGlobalSummary(pm
, "LTTng Kernel Analysis" + testModule
.getTestNameString() + ": " + testName
, Dimension
.CPU_TIME
);
140 for (int i
= 0; i
< LOOP_COUNT
; i
++) {
141 LttngKernelTrace trace
= null;
142 IAnalysisModule module
= null;
143 // TODO Allow the utility method to instantiate trace sub-types
145 String path
= CtfTmfTestTraceUtils
.getTrace(testTrace
).getPath();
148 trace
= new LttngKernelTrace();
149 module
= TestModule
.getNewModule(testModule
);
150 module
.setId("test");
151 trace
.initTrace(null, path
, CtfTmfEvent
.class);
152 module
.setTrace(trace
);
155 TmfTestHelper
.executeAnalysis(module
);
159 * Delete the supplementary files, so that the next iteration
160 * rebuilds the state system.
162 File suppDir
= new File(TmfTraceManager
.getSupplementaryFileDir(trace
));
163 for (File file
: suppDir
.listFiles()) {
167 } catch (TmfAnalysisException
| TmfTraceException e
) {
168 fail(e
.getMessage());
170 if (module
!= null) {
179 CtfTmfTestTraceUtils
.dispose(testTrace
);
This page took 0.04379 seconds and 5 git commands to generate.