Commit | Line | Data |
---|---|---|
72c787e2 | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2014, 2015 École Polytechnique de Montréal |
72c787e2 GB |
3 | * |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Geneviève Bastien - Initial API and implementation | |
11 | * Alexandre Montplaisir - Convert to org.eclipse.test.performance test | |
12 | *******************************************************************************/ | |
13 | ||
9bc60be7 | 14 | package org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis; |
72c787e2 GB |
15 | |
16 | import static org.junit.Assert.fail; | |
17 | import static org.junit.Assume.assumeTrue; | |
18 | ||
19 | import java.io.File; | |
20 | ||
72c787e2 GB |
21 | import org.eclipse.test.performance.Dimension; |
22 | import org.eclipse.test.performance.Performance; | |
23 | import org.eclipse.test.performance.PerformanceMeter; | |
6d16f5a9 | 24 | import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule; |
9bc60be7 | 25 | import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace; |
2bdf0193 AM |
26 | import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; |
27 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException; | |
28 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; | |
29 | import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestHelper; | |
30 | import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; | |
9722e5d7 | 31 | import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent; |
2bdf0193 | 32 | import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTrace; |
72c787e2 GB |
33 | import org.junit.Test; |
34 | ||
35 | /** | |
36 | * This is a test of the time to build a kernel state system | |
37 | * | |
38 | * @author Genevieve Bastien | |
39 | */ | |
40 | public class AnalysisBenchmark { | |
41 | ||
42 | private static final String TEST_ID = "org.eclipse.linuxtools#LTTng kernel analysis"; | |
f14c2f97 | 43 | private static final int LOOP_COUNT = 25; |
72c787e2 GB |
44 | |
45 | /** | |
46 | * Run the benchmark with "trace2" | |
47 | */ | |
48 | @Test | |
49 | public void testTrace2() { | |
50 | runTest(CtfTmfTestTrace.TRACE2, "Trace2"); | |
51 | } | |
52 | ||
53 | private static void runTest(CtfTmfTestTrace testTrace, String testName) { | |
54 | assumeTrue(testTrace.exists()); | |
55 | ||
56 | Performance perf = Performance.getDefault(); | |
57 | PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName); | |
58 | perf.tagAsSummary(pm, "LTTng Kernel Analysis: " + testName, Dimension.CPU_TIME); | |
59 | ||
60 | if (testTrace == CtfTmfTestTrace.TRACE2) { | |
61 | /* Do not show all traces in the global summary */ | |
62 | perf.tagAsGlobalSummary(pm, "LTTng Kernel Analysis: " + testName, Dimension.CPU_TIME); | |
63 | } | |
64 | ||
65 | for (int i = 0; i < LOOP_COUNT; i++) { | |
0ff9e595 | 66 | LttngKernelTrace trace = null; |
03f0b0b1 | 67 | IAnalysisModule module = null; |
0ff9e595 AM |
68 | try { |
69 | trace = new LttngKernelTrace(); | |
6d16f5a9 | 70 | module = new KernelAnalysisModule(); |
72c787e2 GB |
71 | module.setId("test"); |
72 | trace.initTrace(null, testTrace.getPath(), CtfTmfEvent.class); | |
73 | module.setTrace(trace); | |
74 | ||
75 | pm.start(); | |
76 | TmfTestHelper.executeAnalysis(module); | |
77 | pm.stop(); | |
78 | ||
79 | /* | |
80 | * Delete the supplementary files, so that the next iteration | |
81 | * rebuilds the state system. | |
82 | */ | |
83 | File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(trace)); | |
84 | for (File file : suppDir.listFiles()) { | |
85 | file.delete(); | |
86 | } | |
87 | ||
88 | } catch (TmfAnalysisException | TmfTraceException e) { | |
89 | fail(e.getMessage()); | |
03f0b0b1 AM |
90 | } finally { |
91 | if (module != null) { | |
92 | module.dispose(); | |
93 | } | |
0ff9e595 AM |
94 | if (trace != null) { |
95 | trace.dispose(); | |
96 | } | |
72c787e2 | 97 | } |
72c787e2 GB |
98 | } |
99 | pm.commit(); | |
f14c2f97 | 100 | testTrace.dispose(); |
72c787e2 GB |
101 | } |
102 | } |