lttng: Add Lttng Execution Graph analysis benchmarks
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 17 May 2016 20:22:37 +0000 (16:22 -0400)
committerFrancis Giraldeau <francis.giraldeau@gmail.com>
Mon, 27 Jun 2016 14:53:58 +0000 (10:53 -0400)
This benchmarks the build time and memory usage of the kernel execution
graph
analysis on some lttng kernel traces. The graph is used to calculate the
critical path

Change-Id: I7e787f4120f084c1acd5a8fdad835bfdb7e71559
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Francis Giraldeau <francis.giraldeau@gmail.com>
Reviewed-on: https://git.eclipse.org/r/72973
Reviewed-by: Hudson CI
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/execgraph/KernelExecutionGraphBenchmark.java [new file with mode: 0644]
releng/org.eclipse.tracecompass.alltests/src/org/eclipse/tracecompass/alltests/perf/RunAllPerfTests.java

index 0d39bb82c54f6399f19d5a95e781f348c24c3da2..3a4a0275cabd80c992d78cd47679d63c627d7407 100644 (file)
@@ -30,6 +30,7 @@ Export-Package: org.eclipse.tracecompass.lttng2.kernel.core.tests,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.analysis.vm,
  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.execgraph,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.syscall,
  org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.tid,
diff --git a/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/execgraph/KernelExecutionGraphBenchmark.java b/lttng/org.eclipse.tracecompass.lttng2.kernel.core.tests/perf/org/eclipse/tracecompass/lttng2/kernel/core/tests/perf/analysis/execgraph/KernelExecutionGraphBenchmark.java
new file mode 100644 (file)
index 0000000..93b2eda
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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.execgraph;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.EnumSet;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.building.LttngKernelExecutionGraph;
+import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestHelper;
+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;
+
+/**
+ * Benchmarks the kernel execution graph
+ *
+ * @author Geneviève Bastien
+ */
+public class KernelExecutionGraphBenchmark {
+
+    /**
+     * Test test ID for kernel analysis benchmarks
+     */
+    public static final String TEST_ID = "org.eclipse.tracecompass#Kernel Execution Graph#";
+    private static final String TEST_BUILD = "Building Graph (%s)";
+    private static final String TEST_MEMORY = "Memory Usage (%s)";
+
+    private static final int LOOP_COUNT = 25;
+
+    private interface RunMethod {
+        void execute(PerformanceMeter pm, IAnalysisModule module);
+    }
+
+    private RunMethod cpu = (pm, module) -> {
+        pm.start();
+        TmfTestHelper.executeAnalysis(module);
+        pm.stop();
+    };
+
+    private RunMethod memory = (pm, module) -> {
+        System.gc();
+        pm.start();
+        TmfTestHelper.executeAnalysis(module);
+        System.gc();
+        pm.stop();
+    };
+
+    private static final EnumSet<CtfTestTrace> fTraceSet = EnumSet.of(
+            CtfTestTrace.TRACE2,
+            CtfTestTrace.MANY_THREADS,
+            CtfTestTrace.DJANGO_HTTPD);
+
+    /**
+     * Run all benchmarks
+     */
+    @Test
+    public void runAllBenchmarks() {
+        for (CtfTestTrace trace : fTraceSet) {
+
+            runOneBenchmark(trace,
+                    String.format(TEST_BUILD, trace.toString()),
+                    cpu,
+                    Dimension.CPU_TIME);
+
+            runOneBenchmark(trace,
+                    String.format(TEST_MEMORY, trace.toString()),
+                    memory,
+                    Dimension.USED_JAVA_HEAP);
+        }
+    }
+
+    private static void runOneBenchmark(@NonNull CtfTestTrace testTrace, String testName, RunMethod method, Dimension dimension) {
+        Performance perf = Performance.getDefault();
+        PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName);
+        perf.tagAsSummary(pm, "Execution graph " + testName, dimension);
+
+        for (int i = 0; i < LOOP_COUNT; i++) {
+            LttngKernelTrace trace = null;
+            IAnalysisModule module = null;
+
+            String path = CtfTmfTestTraceUtils.getTrace(testTrace).getPath();
+
+            try {
+                trace = new LttngKernelTrace();
+                module = new LttngKernelExecutionGraph();
+                module.setId("test");
+                trace.initTrace(null, path, CtfTmfEvent.class);
+                module.setTrace(trace);
+
+                method.execute(pm, module);
+
+                /*
+                 * Delete the supplementary files, so that the next iteration
+                 * rebuilds the state system.
+                 */
+                File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(trace));
+                for (File file : suppDir.listFiles()) {
+                    file.delete();
+                }
+
+            } catch (TmfAnalysisException | TmfTraceException e) {
+                fail(e.getMessage());
+            } finally {
+                if (module != null) {
+                    module.dispose();
+                }
+                if (trace != null) {
+                    trace.dispose();
+                }
+            }
+        }
+        pm.commit();
+        CtfTmfTestTraceUtils.dispose(testTrace);
+    }
+
+}
index 91823f19b023052087098c4ca1889993e525ac11..7b45acec5f28d72973e4ef1709d7808187435344 100644 (file)
@@ -23,6 +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.execgraph.KernelExecutionGraphBenchmark.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel.KernelAnalysisBenchmark.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.kernel.KernelAnalysisUsageBenchmark.class,
     org.eclipse.tracecompass.lttng2.kernel.core.tests.perf.analysis.syscall.SystemCallAnalysisBenchmark.class,
This page took 0.028443 seconds and 5 git commands to generate.