gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.core.tests / perf / org / eclipse / linuxtools / lttng2 / kernel / core / tests / perf / event / matching / TraceSynchronizationBenchmark.java
index 38bf50c735b0fc969a27f5fdee1162a9deb16988..f4ab323eb62245ee9dbc3aecc8cdfd7eeb43ec0a 100644 (file)
 
 package org.eclipse.linuxtools.lttng2.kernel.core.tests.perf.event.matching;
 
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assume.assumeTrue;
 
+import java.util.Arrays;
+
 import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpEventMatching;
 import org.eclipse.linuxtools.lttng2.kernel.core.event.matching.TcpLttngEventMatching;
 import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatching;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationAlgorithm;
+import org.eclipse.linuxtools.tmf.core.synchronization.SynchronizationManager;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
-import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfEvent;
 import org.eclipse.linuxtools.tmf.ctf.core.CtfTmfTrace;
 import org.eclipse.linuxtools.tmf.ctf.core.tests.shared.CtfTmfTestTrace;
 import org.eclipse.test.performance.Dimension;
 import org.eclipse.test.performance.Performance;
 import org.eclipse.test.performance.PerformanceMeter;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -38,11 +38,10 @@ import org.junit.Test;
  */
 public class TraceSynchronizationBenchmark {
 
-    private static final String TEST_ID = "org.eclipse.linuxtools#Trace synchronization";
+    private static final String TEST_ID = "org.eclipse.linuxtools#Trace synchronization#";
     private static final String TIME = " (time)";
     private static final String MEMORY = " (memory usage)";
     private static final String TEST_SUMMARY = "Trace synchronization";
-    private static int BLOCK_SIZE = 1000;
 
     /**
      * Initialize some data
@@ -69,11 +68,7 @@ public class TraceSynchronizationBenchmark {
 
     /**
      * Run the benchmark with 3 bigger traces
-     *
-     * TODO: For now, this test takes a lot of RAM. To run, remove the @Ignore
-     * and set at least 1024Mb RAM, or else there is OutOfMemoryError exception
      */
-    @Ignore
     @Test
     public void testDjangoTraces() {
         assumeTrue(CtfTmfTestTrace.DJANGO_CLIENT.exists());
@@ -90,20 +85,13 @@ public class TraceSynchronizationBenchmark {
 
     private static void runCpuTest(ITmfTrace[] testTraces, String testName, int loop_count) {
         Performance perf = Performance.getDefault();
-        PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + TIME + '#' + testName);
-        perf.tagAsSummary(pm, TEST_SUMMARY + TIME + ':' + testName, Dimension.CPU_TIME);
+        PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + TIME);
+        perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + TIME, Dimension.CPU_TIME);
 
         for (int i = 0; i < loop_count; i++) {
-            TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", testTraces, BLOCK_SIZE);
-
             pm.start();
-            try {
-                experiment.synchronizeTraces(true);
-            } catch (TmfTraceException e) {
-                fail("Failed at iteration " + i + " with message: " + e.getMessage());
-            }
+            SynchronizationManager.synchronizeTraces(null, Arrays.asList(testTraces), true);
             pm.stop();
-
         }
         pm.commit();
 
@@ -112,22 +100,18 @@ public class TraceSynchronizationBenchmark {
     /* Benchmark memory used by the algorithm */
     private static void runMemoryTest(ITmfTrace[] testTraces, String testName, int loop_count) {
         Performance perf = Performance.getDefault();
-        PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + MEMORY + '#' + testName);
-        perf.tagAsSummary(pm, TEST_SUMMARY + MEMORY + ':' + testName, Dimension.USED_JAVA_HEAP);
+        PerformanceMeter pm = perf.createPerformanceMeter(TEST_ID + testName + MEMORY);
+        perf.tagAsSummary(pm, TEST_SUMMARY + ':' + testName + MEMORY, Dimension.USED_JAVA_HEAP);
 
         for (int i = 0; i < loop_count; i++) {
-            TmfExperiment experiment = new TmfExperiment(CtfTmfEvent.class, "Test experiment", testTraces, BLOCK_SIZE);
 
             System.gc();
             pm.start();
-            try {
-                experiment.synchronizeTraces(true);
-            } catch (TmfTraceException e) {
-                fail("Failed at iteration " + i + " with message: " + e.getMessage());
-            }
+            SynchronizationAlgorithm algo = SynchronizationManager.synchronizeTraces(null, Arrays.asList(testTraces), true);
+            assertNotNull(algo);
+
             System.gc();
             pm.stop();
-
         }
         pm.commit();
     }
This page took 0.026563 seconds and 5 git commands to generate.