1 /*******************************************************************************
2 * Copyright (c) 2014 É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
.linuxtools
.lttng2
.kernel
.core
.tests
.perf
.analysis
;
16 import static org
.junit
.Assert
.fail
;
17 import static org
.junit
.Assume
.assumeTrue
;
21 import org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.analysis
.LttngKernelAnalysisModule
;
22 import org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
.LttngKernelTrace
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.analysis
.IAnalysisModule
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfAnalysisException
;
25 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
26 import org
.eclipse
.linuxtools
.tmf
.core
.tests
.shared
.TmfTestHelper
;
27 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
28 import org
.eclipse
.linuxtools
.tmf
.ctf
.core
.CtfTmfEvent
;
29 import org
.eclipse
.linuxtools
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTrace
;
30 import org
.eclipse
.test
.performance
.Dimension
;
31 import org
.eclipse
.test
.performance
.Performance
;
32 import org
.eclipse
.test
.performance
.PerformanceMeter
;
33 import org
.junit
.Test
;
36 * This is a test of the time to build a kernel state system
38 * @author Genevieve Bastien
40 public class AnalysisBenchmark
{
42 private static final String TEST_ID
= "org.eclipse.linuxtools#LTTng kernel analysis";
43 private static final int LOOP_COUNT
= 25;
46 * Run the benchmark with "trace2"
49 public void testTrace2() {
50 runTest(CtfTmfTestTrace
.TRACE2
, "Trace2");
53 private static void runTest(CtfTmfTestTrace testTrace
, String testName
) {
54 assumeTrue(testTrace
.exists());
56 Performance perf
= Performance
.getDefault();
57 PerformanceMeter pm
= perf
.createPerformanceMeter(TEST_ID
+ '#' + testName
);
58 perf
.tagAsSummary(pm
, "LTTng Kernel Analysis: " + testName
, Dimension
.CPU_TIME
);
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
);
65 for (int i
= 0; i
< LOOP_COUNT
; i
++) {
66 try (IAnalysisModule module
= new LttngKernelAnalysisModule();
67 LttngKernelTrace trace
= new LttngKernelTrace()) {
69 trace
.initTrace(null, testTrace
.getPath(), CtfTmfEvent
.class);
70 module
.setTrace(trace
);
73 TmfTestHelper
.executeAnalysis(module
);
77 * Delete the supplementary files, so that the next iteration
78 * rebuilds the state system.
80 File suppDir
= new File(TmfTraceManager
.getSupplementaryFileDir(trace
));
81 for (File file
: suppDir
.listFiles()) {
85 } catch (TmfAnalysisException
| TmfTraceException e
) {