<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="perf"/>
<classpathentry kind="src" path="shared"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
Export-Package: org.eclipse.linuxtools.ctf.core.tests;x-friends:="org.eclipse.linuxtools.lttng.alltests",
org.eclipse.linuxtools.ctf.core.tests.ctftestsuite;x-internal:=true,
org.eclipse.linuxtools.ctf.core.tests.event;x-internal:=true,
- org.eclipse.linuxtools.ctf.core.tests.headless;x-internal:=true,
org.eclipse.linuxtools.ctf.core.tests.io;x-internal:=true,
+ org.eclipse.linuxtools.ctf.core.tests.perf,
+ org.eclipse.linuxtools.ctf.core.tests.perf.trace;x-internal:=true,
org.eclipse.linuxtools.ctf.core.tests.scope,
org.eclipse.linuxtools.ctf.core.tests.shared,
org.eclipse.linuxtools.ctf.core.tests.synthetictraces;x-internal:=true,
org.eclipse.linuxtools.ctf.core.tests.trace;x-internal:=true,
org.eclipse.linuxtools.ctf.core.tests.types;x-internal:=true
Import-Package: com.google.common.collect,
- org.antlr.runtime;version="3.2.0"
+ org.antlr.runtime;version="3.2.0",
+ org.eclipse.test.performance
###############################################################################
source.. = shared,\
- src/
+ src/,\
+ perf/
output.. = bin/
bin.includes = META-INF/,\
.,\
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * 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:
+ * Alexandre Montplaisir - Initial implementation and API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.ctf.core.tests.perf;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Run all performance test suites.
+ *
+ * @author Alexandre Montplaisir
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ org.eclipse.linuxtools.ctf.core.tests.perf.trace.AllPerfTests.class
+})
+public class AllPerfTests {
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * 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:
+ * Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.ctf.core.tests.perf.trace;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TraceReadBenchmark.class,
+ TraceSeekBenchmark.class
+})
+public class AllPerfTests {
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Ericsson
+ *
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ * Alexandre Montplaisir - Convert to a org.eclipse.test.performance test
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.ctf.core.tests.perf.trace;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
+import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
+import org.junit.Test;
+
+/**
+ * Benchmark of the CTF parser for reading a trace
+ *
+ * @author Matthew Khouzam
+ * @author Alexandre Montplaisir
+ */
+public class TraceReadBenchmark {
+
+ private static final String TEST_SUITE_NAME = "CTF Read Benchmark";
+ private static final String TEST_ID = "org.eclipse.linuxtools#" + TEST_SUITE_NAME;
+ private static final int LOOP_COUNT = 25;
+
+ /**
+ * Benchmark reading the trace "kernel"
+ */
+ @Test
+ public void testKernelTrace() {
+ readTrace(CtfTestTrace.KERNEL, "trace-kernel", true);
+ }
+
+ /**
+ * Benchmark reading the bigger trace "kernel_vm"
+ */
+ @Test
+ public void testKernelVmTrace() {
+ readTrace(CtfTestTrace.KERNEL_VM, "trace-kernel-vm", false);
+ }
+
+ private static void readTrace(CtfTestTrace testTrace, String testName, boolean inGlobalSummary) {
+ assumeTrue(testTrace.exists());
+
+ Performance perf = Performance.getDefault();
+ PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName);
+ perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME);
+
+ if (inGlobalSummary) {
+ perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME);
+ }
+
+ for (int loop = 0; loop < LOOP_COUNT; loop++) {
+ pm.start();
+ try (CTFTrace trace = testTrace.getTrace();
+ CTFTraceReader traceReader = new CTFTraceReader(trace);) {
+
+ while (traceReader.hasMoreEvents()) {
+ EventDefinition ed = traceReader.getCurrentEventDef();
+ /* Do something with the event */
+ ed.getCPU();
+ traceReader.advance();
+ }
+
+ } catch (CTFReaderException e) {
+ /* Should not happen if assumeTrue() passed above */
+ fail("Test failed at iteration " + loop + ':' + e.getMessage());
+ }
+ pm.stop();
+ }
+ pm.commit();
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012, 2014 Ericsson
+ *
+ * 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:
+ * Matthew Khouzam - Initial API and implementation
+ * Alexandre Montplaisir - Convert to a org.eclipse.test.performance test
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.ctf.core.tests.perf.trace;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
+import org.eclipse.linuxtools.ctf.core.tests.shared.CtfTestTrace;
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.Performance;
+import org.eclipse.test.performance.PerformanceMeter;
+import org.junit.Test;
+
+/**
+ * Tests for performance regressions of the ctf reader. It only tests the ctf
+ * reader, not tmf.
+ * <br>
+ * This test runs in 3 passes.
+ * <ul>
+ * <li>first it opens a trace</li>
+ * <li>then it reads the trace completely</li>
+ * <li>then it randomly (seeded) seeks NB_SEEKS locations in the trace and reads one
+ * event at each position.</li>
+ * </ul>
+ *
+ * @author Matthew Khouzam
+ * @author Alexandre Montplaisir
+ */
+public class TraceSeekBenchmark {
+
+ private static final Random RND = new Random(1000);
+
+ private static final int LOOP_COUNT = 25;
+ private static final int NB_SEEKS = 500;
+ private static final String TEST_SUITE_NAME = "CTF Read & Seek Benchmark (" + NB_SEEKS + " seeks)";
+ private static final String TEST_ID = "org.eclipse.linuxtools#" + TEST_SUITE_NAME;
+
+ /**
+ * Run the benchmark scenario for the trace "kernel"
+ */
+ @Test
+ public void testKernelTrace() {
+ readAndSeekTrace(CtfTestTrace.KERNEL, "trace-kernel", true);
+ }
+
+ private static void readAndSeekTrace(CtfTestTrace testTrace, String testName, boolean inGlobalSummary) {
+ assumeTrue(testTrace.exists());
+
+ Performance perf = Performance.getDefault();
+ PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + '#' + testName);
+ perf.tagAsSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME);
+
+ if (inGlobalSummary) {
+ perf.tagAsGlobalSummary(pm, TEST_SUITE_NAME + ':' + testName, Dimension.CPU_TIME);
+ }
+
+ for (int loop = 0; loop < LOOP_COUNT; loop++) {
+ try (CTFTrace trace = testTrace.getTrace();
+ CTFTraceReader traceReader = new CTFTraceReader(trace);) {
+
+ /* Read the whole trace to find out the start and end times */
+ EventDefinition firstEvent = traceReader.getCurrentEventDef();
+ final long startTime = firstEvent.getTimestamp();
+ long endTime = startTime;
+ while (traceReader.hasMoreEvents()) {
+ EventDefinition ev = traceReader.getCurrentEventDef();
+ endTime = ev.getTimestamp();
+ traceReader.advance();
+ }
+
+ /* Generate the timestamps we will seek to */
+ List<Long> seekTimestamps = new LinkedList<>();
+ final long range = endTime - startTime;
+ for (int i = 0; i < NB_SEEKS; i++) {
+ seekTimestamps.add(startTime + (RND.nextLong() % range));
+ }
+
+ /* Benchmark seeking to the generated timestamps */
+ pm.start();
+ for (Long ts : seekTimestamps) {
+ traceReader.seek(ts);
+ traceReader.advance();
+ }
+ pm.stop();
+
+ } catch (CTFReaderException e) {
+ /* Should not happen if assumeTrue() passed above */
+ fail("Test failed at iteration " + loop + ':' + e.getMessage());
+ }
+ }
+ pm.commit();
+ }
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
- *
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.tests.headless;
-
-import java.io.FileNotFoundException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Vector;
-
-import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
-import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
-
-@SuppressWarnings("javadoc")
-public class ReadTrace {
-
- /**
- * @param args
- * @throws FileNotFoundException
- */
- public static void main(String[] args) throws FileNotFoundException {
- final String TRACE_PATH = "traces/kernel";
-
- // Change this to enable text output
- final boolean USE_TEXT = false;
-
- final int LOOP_COUNT = 10;
-
- // Work variables
- long nbEvent = 0L;
- Vector<Double> benchs = new Vector<>();
- long start, stop;
- for (int loops = 0; loops < LOOP_COUNT; loops++) {
- try (CTFTrace trace = new CTFTrace(TRACE_PATH);) {
- nbEvent = 0L;
-
- start = System.nanoTime();
- if (USE_TEXT) {
- System.out.println("Event, " + " Time, " + " type, " + " CPU ");
- }
- try (CTFTraceReader traceReader = new CTFTraceReader(trace);) {
- start = System.nanoTime();
-
- while (traceReader.hasMoreEvents()) {
- EventDefinition ed = traceReader.getCurrentEventDef();
- nbEvent++;
- if (USE_TEXT) {
- String output = formatDate(ed.getTimestamp()
- + trace.getOffset());
- System.out.println(nbEvent + ", "
- + output + ", " + ed.getDeclaration().getName()
- + ", " + ed.getCPU() + ed.getFields().toString());
- }
-
- traceReader.advance();
- }
-
- stop = System.nanoTime();
-
- System.out.print('.');
- double time = (stop - start) / (double) nbEvent;
- benchs.add(time);
- } catch (CTFReaderException e) {
- System.out.println("error");
- }
- } catch (CTFReaderException e) {
- throw new FileNotFoundException(TRACE_PATH);
- }
- }
- System.out.println("");
- double avg = 0;
- for (Double val : benchs) {
- avg += val;
- }
- avg /= benchs.size();
- System.out.println("Time to read " + nbEvent + " events = " + avg
- + " ns/event");
- for (Double val : benchs) {
- System.out.print(val);
- System.out.print(", ");
- }
- }
-
- /**
- * @param timestamp
- * the timestamp in UTC to convert to nanoseconds.
- * @return formatted string.
- */
- private static String formatDate(long timestamp) {
- Date d = new Date(timestamp / 1000000);
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.");
- String output = df.format(d) + (timestamp % 1000000000);
- return output;
- }
-}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
- *
- * 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:
- * Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.tests.headless;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Random;
-import java.util.Vector;
-
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
-import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
-
-/**
- * Tests for performance regressions of the ctf reader. It only tests the ctf
- * reader, not tmf. You can give it the arguments : <b>trace path</b>(trace to
- * read), <b>output file</b>(the path to the resulting output) and <b>title</b>
- * (The name of this benchmark run) <br>
- * <br>
- * This test runs in 3 passes.
- * <ul>
- * <li>first it opens a trace</li>
- * <li>then it reads the trace completely</li>
- * <li>then it randomly (seeded) seeks 1000 locations in the trace and reads one
- * event after</li>
- * </ul>
- *
- * @author Matthew Khouzam
- *
- */
-public class ReadTraceBenchmark {
-
- /**
- * @param args
- * Tracepath, where to store, title
- * @throws IOException
- * file not found or such
- */
- public static void main(String[] args) throws IOException {
- String tracePath = "traces/kernel";
- String outFile = "results.csv";
- String title = "run a";
- Random random = new Random(1000);
- if (args.length > 0) {
- tracePath = args[0];
- }
- if (args.length > 1) {
- outFile = args[1];
- }
- if (args.length > 2) {
- title = args[2];
- }
-
- final int LOOP_COUNT = 4;
-
- Vector<Long> timestamps = new Vector<>();
- for (int i = 0; i < 500; i++) {
- long start = 4277198419110L;
- long range = 4287422865814L - 4277198419110L;
- timestamps.add(start + (random.nextLong() % range));
- }
-
- // Work variables
- long nbEvent = 0L;
- Vector<Long> openTime = new Vector<>();
- Vector<Double> benchs = new Vector<>();
- Vector<Double> seeks = new Vector<>();
-
- long start, stop;
- double time;
- for (int loops = 0; loops < LOOP_COUNT; loops++) {
- start = System.nanoTime();
- try (CTFTrace trace = new CTFTrace(tracePath);) {
- nbEvent = 0L;
- stop = System.nanoTime();
- openTime.add(stop - start);
- start = System.nanoTime();
- try (CTFTraceReader traceReader = new CTFTraceReader(trace);) {
- start = System.nanoTime();
-
- while (traceReader.hasMoreEvents()) {
- traceReader.getCurrentEventDef();
- nbEvent++;
- traceReader.advance();
- }
- stop = System.nanoTime();
-
- time = (stop - start) / (double) nbEvent;
- benchs.add(time);
- start = System.nanoTime();
- for (Long ts : timestamps) {
- traceReader.seek(ts);
- traceReader.advance();
- }
- stop = System.nanoTime();
- seeks.add((double) (stop - start) / timestamps.size());
- } catch (CTFReaderException e) {
- System.out.println("error");
- }
- } catch (CTFReaderException e) {
- // do nothing
- }
- }
- System.out.println("");
- double avg = 0;
- for (Double val : benchs) {
- avg += val;
- }
- avg /= benchs.size();
- System.out.println("Time to read " + nbEvent + " events = " + avg
- + " ns/event");
- File output = new File(outFile);
- boolean writeHeader = !output.exists();
- try (FileOutputStream fos = new FileOutputStream(output, true)) {
- if (writeHeader) {
- fos.write(new String("title,open time(us),read time(us),seeks(us) \n").getBytes());
- }
- for (int i = 0; i < LOOP_COUNT; i++) {
- fos.write(new String(title + "," + openTime.get(i) * 0.001 + "," + benchs.get(i) * 0.001 + "," + seeks.get(i) * 0.001 + "\n").getBytes());
- }
- }
- }
-}
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ org.eclipse.linuxtools.ctf.core.tests.perf.AllPerfTests.class,
org.eclipse.linuxtools.lttng2.kernel.core.tests.perf.AllPerfTests.class,
org.eclipse.linuxtools.tmf.ctf.core.tests.perf.AllPerfTests.class
})