From 088b4f19605a38f3c5511002e933d73128944044 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Genevi=C3=A8ve=20Bastien?= Date: Mon, 9 Jun 2014 15:33:28 -0400 Subject: [PATCH] tmf: Introduce performance tests to TMF MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add separate source directories in test packages specifically for performance tests based on org.eclipse.test.performance. Change-Id: Ia28d5269a6ba81f0727eb2a65858c97566dbf1d9 Signed-off-by: Geneviève Bastien Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/28282 Tested-by: Hudson CI --- .../lttng/alltests/RunAllPerfTests.java | 27 +++ .../.classpath | 1 + .../META-INF/MANIFEST.MF | 3 + .../build.properties | 1 + .../tmf/ctf/core/tests/perf/AllPerfTests.java | 31 ++++ .../tests/perf/experiment/AllPerfTests.java | 26 +++ .../perf/experiment}/ExperimentBenchmark.java | 156 ++++++++---------- 7 files changed, 156 insertions(+), 89 deletions(-) create mode 100644 org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java create mode 100644 org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/AllPerfTests.java create mode 100644 org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/AllPerfTests.java rename org.eclipse.linuxtools.tmf.ctf.core.tests/{src/org/eclipse/linuxtools/tmf/ctf/core/tests/headless => perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment}/ExperimentBenchmark.java (50%) diff --git a/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java b/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java new file mode 100644 index 0000000000..1fa5099aaf --- /dev/null +++ b/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2014 É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 + * + * Contributors: + * Geneviève Bastien - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.lttng.alltests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Master test suite for all Linux Tools LTTng performance tests. + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + org.eclipse.linuxtools.tmf.ctf.core.tests.perf.AllPerfTests.class +}) +public class RunAllPerfTests { + +} diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/.classpath b/org.eclipse.linuxtools.tmf.ctf.core.tests/.classpath index 68143fe727..11921cabe4 100644 --- a/org.eclipse.linuxtools.tmf.ctf.core.tests/.classpath +++ b/org.eclipse.linuxtools.tmf.ctf.core.tests/.classpath @@ -3,6 +3,7 @@ + diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.tmf.ctf.core.tests/META-INF/MANIFEST.MF index 6f9c9e50c1..a17b351b6a 100644 --- a/org.eclipse.linuxtools.tmf.ctf.core.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.tmf.ctf.core.tests/META-INF/MANIFEST.MF @@ -17,8 +17,11 @@ Require-Bundle: org.junit;bundle-version="4.0.0", org.eclipse.linuxtools.ctf.core.tests Export-Package: org.eclipse.linuxtools.tmf.ctf.core.tests, org.eclipse.linuxtools.tmf.ctf.core.tests.headless;x-internal:=true, + org.eclipse.linuxtools.tmf.ctf.core.tests.perf, + org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment;x-internal:=true, org.eclipse.linuxtools.tmf.ctf.core.tests.request;x-internal:=true, org.eclipse.linuxtools.tmf.ctf.core.tests.shared, org.eclipse.linuxtools.tmf.ctf.core.tests.statistics;x-internal:=true, org.eclipse.linuxtools.tmf.ctf.core.tests.stubs, org.eclipse.linuxtools.tmf.ctf.core.tests.tracemanager;x-internal:=true +Import-Package: org.eclipse.test.performance diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/build.properties b/org.eclipse.linuxtools.tmf.ctf.core.tests/build.properties index 9f2d161159..2f7d89bee1 100644 --- a/org.eclipse.linuxtools.tmf.ctf.core.tests/build.properties +++ b/org.eclipse.linuxtools.tmf.ctf.core.tests/build.properties @@ -11,6 +11,7 @@ ############################################################################### source.. = src/,\ + perf/,\ shared/,\ stubs output.. = bin/ diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/AllPerfTests.java b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/AllPerfTests.java new file mode 100644 index 0000000000..630b212ea1 --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/AllPerfTests.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2014 É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 + * + * Contributors: + * Geneviève Bastien - Initial implementation and API + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ctf.core.tests.perf; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * The class AllPerformanceTests builds a suite that can be used to + * run all of the performance tests within its package as well as within any + * subpackages of its package. + * + * @author Geneviève Bastien + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment.AllPerfTests.class +}) +public class AllPerfTests { + +} diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/AllPerfTests.java b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/AllPerfTests.java new file mode 100644 index 0000000000..c7727eadfe --- /dev/null +++ b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/AllPerfTests.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2014 É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 + * + * Contributors: + * Geneviève Bastien - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * Test suite + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + ExperimentBenchmark.class +}) +public class AllPerfTests { +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/headless/ExperimentBenchmark.java b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/ExperimentBenchmark.java similarity index 50% rename from org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/headless/ExperimentBenchmark.java rename to org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/ExperimentBenchmark.java index a5f8cebe7f..5c038b3c0e 100644 --- a/org.eclipse.linuxtools.tmf.ctf.core.tests/src/org/eclipse/linuxtools/tmf/ctf/core/tests/headless/ExperimentBenchmark.java +++ b/org.eclipse.linuxtools.tmf.ctf.core.tests/perf/org/eclipse/linuxtools/tmf/ctf/core/tests/perf/experiment/ExperimentBenchmark.java @@ -8,9 +8,10 @@ * * Contributors: * Matthew Khouzam - Initial API and implementation + * Geneviève Bastien - Convert to JUnit performance test *******************************************************************************/ -package org.eclipse.linuxtools.tmf.ctf.core.tests.headless; +package org.eclipse.linuxtools.tmf.ctf.core.tests.perf.experiment; import java.io.File; import java.util.Arrays; @@ -27,119 +28,103 @@ import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace; import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfExperimentStub; +import org.eclipse.test.performance.Dimension; +import org.eclipse.test.performance.Performance; +import org.eclipse.test.performance.PerformanceMeter; +import org.junit.Test; /** * Coalescing benchmark * * @author Matthew Khouzam - * */ public class ExperimentBenchmark { + + private static final String TEST_ID = "org.eclipse.linuxtools#Experiment benchmark"; private static final int MAX_TRACES = 160; private static final int BLOCK_SIZE = 100; private static final String TRACES_ROOT_PATH = CtfTestTrace.TRACE_EXPERIMENT.getPath(); - private ITmfTrace[] traces; - private TmfExperimentStub fExperiment; + private static final int SAMPLE_SIZE = 5; - /** - * initialization - * - * @param maxTraces - * maximum number of traces to open - * - * @throws TmfTraceException - * problem - */ - private void init(int maxTraces) throws TmfTraceException { - File parentDir = new File(TRACES_ROOT_PATH); - File[] traceFiles = parentDir.listFiles(); - traces = new CtfTmfTrace[Math.min(maxTraces, traceFiles.length)]; - for (int i = 0; i < traces.length; i++) { - traces[i] = new CtfTmfTrace(); - } - fExperiment = new TmfExperimentStub("MegaExperiment", traces, BLOCK_SIZE); - int j = 0; - for (int i = 0; i < (traces.length) && (j < traces.length); i++) { - String absolutePath = traceFiles[j].getAbsolutePath(); - if (traces[i].validate(null, absolutePath).isOK()) { - traces[i].initTrace(null, absolutePath, ITmfEvent.class); - } else { - i--; - } - j++; - } - if (traces[traces.length - 1].getPath() == null) { - throw new TmfTraceException("Insufficient valid traces in directory"); - } - - } - - /** - * Main benchmark - * - * @param args - * benchmark - */ - public static void main(final String[] args) { - ExperimentBenchmark eb = new ExperimentBenchmark(); - eb.testRun(); - - } + private TmfExperimentStub fExperiment; /** * Run the benchmark */ - public void testRun() { - System.out.println("Test, init, request, dispose"); + @Test + public void benchmarkExperimentSizeRequest() { + Performance perf = Performance.getDefault(); + + for (int numTraces = 1; numTraces < MAX_TRACES; numTraces = (int) (1.6 * (numTraces + 1))) { + PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '(' + numTraces + ')'); + perf.tagAsSummary(pm, "Experiment Benchmark traces:" + numTraces, Dimension.CPU_TIME); + if ((int) (1.6 * (numTraces + 1)) > MAX_TRACES) { + perf.tagAsGlobalSummary(pm, "Experiment Benchmark traces: " + numTraces, Dimension.CPU_TIME); + } - for (int numTraces = 1; numTraces < MAX_TRACES; numTraces = (int) (1.1 * (numTraces + 1))) { - InnerEventRequest expReq = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND); + for (int s = 0; s < SAMPLE_SIZE; s++) { - InnerEventRequest traceReq[] = new InnerEventRequest[numTraces]; + InnerEventRequest expReq = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND); + InnerEventRequest traceReq[] = new InnerEventRequest[numTraces]; - System.out.print(numTraces); + init(numTraces); + fExperiment.sendRequest(expReq); + ITmfTrace[] traces = fExperiment.getTraces(); + for (int i = 0; i < numTraces; i++) { + traceReq[i] = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND); + traces[i].sendRequest(traceReq[i]); + } - waitForInit(numTraces); - fExperiment.sendRequest(expReq); - for (int i = 0; i < numTraces; i++) { - traceReq[i] = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND); - traces[i].sendRequest(traceReq[i]); - } - waitForRequest(expReq, traceReq); + pm.start(); + waitForRequest(expReq, traceReq); + pm.stop(); - for (int i = 0; i < traces.length; i++) { - if (!expReq.isTraceHandled(traces[i])) { - System.err.println("Trace " + i + " not handled!"); + for (int i = 0; i < traces.length; i++) { + if (!expReq.isTraceHandled(traces[i])) { + System.err.println("Trace " + i + " not handled!"); + } } - } - waitForDispose(); - System.out.println(""); - } - } - private void waitForDispose() { - long start = System.nanoTime(); - fExperiment.dispose(); - for (int i = 0; i < traces.length; i++) { - traces[i].dispose(); + fExperiment.dispose(); + } + pm.commit(); } - long end = System.nanoTime(); - printTime(start, end); } - private void waitForInit(int numTraces) { - long start = System.nanoTime(); + /** + * Initialization + * + * @param maxTraces + * maximum number of traces to open + */ + private void init(int maxTraces) { try { - init(numTraces); + File parentDir = new File(TRACES_ROOT_PATH); + File[] traceFiles = parentDir.listFiles(); + ITmfTrace[] traces = new CtfTmfTrace[Math.min(maxTraces, traceFiles.length)]; + for (int i = 0; i < traces.length; i++) { + traces[i] = new CtfTmfTrace(); + } + fExperiment = new TmfExperimentStub("MegaExperiment", traces, BLOCK_SIZE); + int j = 0; + for (int i = 0; i < (traces.length) && (j < traces.length); i++) { + String absolutePath = traceFiles[j].getAbsolutePath(); + if (traces[i].validate(null, absolutePath).isOK()) { + traces[i].initTrace(null, absolutePath, ITmfEvent.class); + } else { + i--; + } + j++; + } + if (traces[traces.length - 1].getPath() == null) { + throw new TmfTraceException("Insufficient valid traces in directory"); + } } catch (TmfTraceException e) { System.out.println(e.getMessage()); } - long end = System.nanoTime(); - printTime(start, end); } private static void waitForRequest(InnerEventRequest expReq, InnerEventRequest[] traceReqs) { - long start = System.nanoTime(); try { expReq.waitForCompletion(); List reqs = Arrays.asList(traceReqs); @@ -148,13 +133,6 @@ public class ExperimentBenchmark { } } catch (InterruptedException e) { } - long end = System.nanoTime(); - printTime(start, end); - } - - private static void printTime(long start, long end) { - /* print out the difference between the two nanosecond times in ms */ - System.out.format(", %.3f", 0.000000001 * (end - start)); } private static class InnerEventRequest extends TmfEventRequest { -- 2.34.1