Actually add the profile to run the benchmarks
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Sat, 25 Jul 2015 06:51:34 +0000 (02:51 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Sat, 25 Jul 2015 07:04:19 +0000 (03:04 -0400)
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
13 files changed:
pom.xml
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/AbstractJulBenchmark.java [deleted file]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/DummyHandlerBenchmark.java [deleted file]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/FileHandlerBenchmark.java [deleted file]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java [new file with mode: 0644]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/NoHandlerBenchmark.java [deleted file]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java [new file with mode: 0644]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java [new file with mode: 0644]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java [new file with mode: 0644]
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingDisabledBenchmark.java
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/LttngJulHandlerTracingEnabledBenchmark.java
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingDisabledBenchmark.java
src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/lttng/old/OldLttngJulHandlerTracingEnabledBenchmark.java

diff --git a/pom.xml b/pom.xml
index e5ec7907c6eded72e57b317bd745855416805303..fe19978cc4bed24d29ced5d490279fa16ce564cf 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
+  <prerequisites>
+    <maven>3.0</maven>
+  </prerequisites>
+
   <groupId>org.lttng.ust.agent</groupId>
   <artifactId>lttng-ust-agent-tests</artifactId>
   <version>1.0.0</version>
@@ -82,7 +86,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.1</version>
+        <version>3.3</version>
         <configuration>
           <source>1.8</source>
           <target>1.8</target>
     </plugins>
   </build>
 
+  <profiles>
+    <profile>
+      <id>benchmark</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <version>2.18.1</version>
+            <configuration>
+              <includes>
+                <include>**/*Benchmark.java</include>
+              </includes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
 </project>
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/AbstractJulBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/AbstractJulBenchmark.java
deleted file mode 100644 (file)
index a089e9d..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public abstract class AbstractJulBenchmark {
-
-    // ------------------------------------------------------------------------
-    // Configurable test parameters
-    // ------------------------------------------------------------------------
-
-    /** Nb of runs per test, result will be averaged */
-    private static final int NB_RUNS = 10;
-
-    /** Trace/log events per run */
-    private static final int NB_ITER = 100000;
-
-    /** Which tests to run (for different number of threads) */
-    private static final int[] NB_THREADS = {1, 1, 2, 3, 4, 5, 6, 7, 8};
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-
-    protected Logger logger;
-    protected Handler handler;
-
-    // ------------------------------------------------------------------------
-    // Maintenance methods
-    // ------------------------------------------------------------------------
-
-    @Before
-    public void setup() {
-        /* Set up the logger */
-        logger = Logger.getLogger("Test logger");
-        logger.setUseParentHandlers(false);
-        logger.setLevel(Level.ALL);
-
-        /* Sub-classes' @Before will setup the Handler */
-    }
-
-    @After
-    public void teardown() {
-        if (handler != null) {
-            logger.removeHandler(handler);
-            handler.close();
-        }
-        handler = null;
-        logger = null;
-    }
-
-    // ------------------------------------------------------------------------
-    // Test methods
-    // ------------------------------------------------------------------------
-
-    @Test
-    public void runBenchmark() {
-        if (handler != null) {
-            logger.addHandler(handler);
-        }
-
-        System.out.println();
-        System.out.println("Running benchmark: " + this.getClass().getCanonicalName());
-        for (int i : NB_THREADS) {
-            runTest(logger, i);
-        }
-    }
-
-    private static void runTest(Logger log, int nbThreads) {
-        long start, end, average, total = 0;
-        for (int i = 0; i < NB_RUNS; i++) {
-            Runner runner = new Runner(nbThreads, NB_ITER, log);
-
-            start = System.nanoTime();
-            runner.run();
-            end = System.nanoTime();
-
-            total += (end - start);
-        }
-        average = total / NB_RUNS;
-        System.out.println(nbThreads + " threads, average = " + average / NB_ITER + " ns/event");
-    }
-
-    // ------------------------------------------------------------------------
-    // Helper classes
-    // ------------------------------------------------------------------------
-
-    private static class Runner implements Runnable {
-
-        private final List<Worker> workers = new LinkedList<>();
-        private final List<Thread> workerThreads = new LinkedList<>();
-
-        public Runner(int nbThreads, int nbIter, Logger log) {
-
-            for (int id = 0; id < nbThreads; id++) {
-                Worker curWorker = new Worker(id, nbIter, log);
-                workers.add(curWorker);
-                workerThreads.add(new Thread(curWorker, "worker " + id));
-            }
-        }
-
-        @Override
-        public void run() {
-            for (Thread curThread : workerThreads) {
-                curThread.start();
-            }
-
-            for (Thread curThread : workerThreads) {
-                try {
-                    curThread.join();
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-
-        private static class Worker implements Runnable {
-
-            private final Logger log;
-            private final int threadId;
-            private final int nbIter;
-
-            public Worker(int threadId, int nbIter, Logger log) {
-                this.log = log;
-                this.threadId = threadId;
-                this.nbIter = nbIter;
-            }
-
-            @Override
-            public void run() {
-                for (int i = 0; i < nbIter; i++) {
-                    log.info("Thread " + threadId + ", iteration " + i);
-                }
-            }
-
-        }
-    }
-}
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/DummyHandlerBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/DummyHandlerBenchmark.java
deleted file mode 100644 (file)
index d962b42..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-
-import org.junit.Before;
-
-public class DummyHandlerBenchmark extends AbstractJulBenchmark {
-
-    @Before
-    public void testSetup() {
-        handler = new DummyHandler();
-    }
-
-    private static class DummyHandler extends Handler {
-
-        public DummyHandler() {
-            super();
-        }
-
-        @Override
-        public void close() throws SecurityException {}
-
-        @Override
-        public void flush() {}
-
-        @Override
-        public void publish(LogRecord record) {}
-
-    }
-}
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/FileHandlerBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/FileHandlerBenchmark.java
deleted file mode 100644 (file)
index 167c741..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.logging.FileHandler;
-import java.util.logging.SimpleFormatter;
-
-import org.junit.After;
-import org.junit.Before;
-
-public class FileHandlerBenchmark extends AbstractJulBenchmark {
-
-    private Path outputFile;
-
-    @Before
-    public void testSetup() throws SecurityException, IOException {
-        outputFile = Files.createTempFile(this.getClass().getSimpleName(), null);
-
-        handler = new FileHandler(outputFile.toString(), false);
-        handler.setFormatter(new SimpleFormatter());
-    }
-
-    @After
-    public void testTeardown() throws IOException {
-        Files.deleteIfExists(outputFile);
-    }
-}
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/JulHandlerBenchmarkBase.java
new file mode 100644 (file)
index 0000000..dbfd331
--- /dev/null
@@ -0,0 +1,145 @@
+package org.lttng.ust.agent.benchmarks.jul.handler;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class JulHandlerBenchmarkBase {
+
+    // ------------------------------------------------------------------------
+    // Configurable test parameters
+    // ------------------------------------------------------------------------
+
+    /** Nb of runs per test, result will be averaged */
+    private static final int NB_RUNS = 10;
+
+    /** Trace/log events per run */
+    private static final int NB_ITER = 100000;
+
+    /** Which tests to run (for different number of threads) */
+    private static final int[] NB_THREADS = {1, 1, 2, 3, 4, 5, 6, 7, 8};
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    protected Logger logger;
+    protected Handler handler;
+
+    // ------------------------------------------------------------------------
+    // Maintenance methods
+    // ------------------------------------------------------------------------
+
+    @Before
+    public void setup() {
+        /* Set up the logger */
+        logger = Logger.getLogger("Test logger");
+        logger.setUseParentHandlers(false);
+        logger.setLevel(Level.ALL);
+
+        /* Sub-classes' @Before will setup the Handler */
+    }
+
+    @After
+    public void teardown() {
+        if (handler != null) {
+            logger.removeHandler(handler);
+            handler.close();
+        }
+        handler = null;
+        logger = null;
+    }
+
+    // ------------------------------------------------------------------------
+    // Test methods
+    // ------------------------------------------------------------------------
+
+    @Test
+    public void runBenchmark() {
+        if (handler != null) {
+            logger.addHandler(handler);
+        }
+
+        System.out.println();
+        System.out.println("Running benchmark: " + this.getClass().getCanonicalName());
+        for (int i : NB_THREADS) {
+            runTest(logger, i);
+        }
+    }
+
+    private static void runTest(Logger log, int nbThreads) {
+        long start, end, average, total = 0;
+        for (int i = 0; i < NB_RUNS; i++) {
+            Runner runner = new Runner(nbThreads, NB_ITER, log);
+
+            start = System.nanoTime();
+            runner.run();
+            end = System.nanoTime();
+
+            total += (end - start);
+        }
+        average = total / NB_RUNS;
+        System.out.println(nbThreads + " threads, average = " + average / NB_ITER + " ns/event");
+    }
+
+    // ------------------------------------------------------------------------
+    // Helper classes
+    // ------------------------------------------------------------------------
+
+    private static class Runner implements Runnable {
+
+        private final List<Worker> workers = new LinkedList<>();
+        private final List<Thread> workerThreads = new LinkedList<>();
+
+        public Runner(int nbThreads, int nbIter, Logger log) {
+
+            for (int id = 0; id < nbThreads; id++) {
+                Worker curWorker = new Worker(id, nbIter, log);
+                workers.add(curWorker);
+                workerThreads.add(new Thread(curWorker, "worker " + id));
+            }
+        }
+
+        @Override
+        public void run() {
+            for (Thread curThread : workerThreads) {
+                curThread.start();
+            }
+
+            for (Thread curThread : workerThreads) {
+                try {
+                    curThread.join();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+        private static class Worker implements Runnable {
+
+            private final Logger log;
+            private final int threadId;
+            private final int nbIter;
+
+            public Worker(int threadId, int nbIter, Logger log) {
+                this.log = log;
+                this.threadId = threadId;
+                this.nbIter = nbIter;
+            }
+
+            @Override
+            public void run() {
+                for (int i = 0; i < nbIter; i++) {
+                    log.info("Thread " + threadId + ", iteration " + i);
+                }
+            }
+
+        }
+    }
+}
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/NoHandlerBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/NoHandlerBenchmark.java
deleted file mode 100644 (file)
index 424b32e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.lttng.ust.agent.benchmarks.jul.handler;
-
-public class NoHandlerBenchmark extends AbstractJulBenchmark {
-
-    /* Do not setup any handler */
-}
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/DummyHandlerBenchmark.java
new file mode 100644 (file)
index 0000000..cc867cb
--- /dev/null
@@ -0,0 +1,32 @@
+package org.lttng.ust.agent.benchmarks.jul.handler.builtin;
+
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+import org.junit.Before;
+import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
+
+public class DummyHandlerBenchmark extends JulHandlerBenchmarkBase {
+
+       @Before
+       public void testSetup() {
+               handler = new DummyHandler();
+       }
+
+       private static class DummyHandler extends Handler {
+
+               public DummyHandler() {
+                       super();
+               }
+
+               @Override
+               public void close() throws SecurityException {}
+
+               @Override
+               public void flush() {}
+
+               @Override
+               public void publish(LogRecord record) {}
+
+       }
+}
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/FileHandlerBenchmark.java
new file mode 100644 (file)
index 0000000..41a8bae
--- /dev/null
@@ -0,0 +1,29 @@
+package org.lttng.ust.agent.benchmarks.jul.handler.builtin;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.logging.FileHandler;
+import java.util.logging.SimpleFormatter;
+
+import org.junit.After;
+import org.junit.Before;
+import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
+
+public class FileHandlerBenchmark extends JulHandlerBenchmarkBase {
+
+    private Path outputFile;
+
+    @Before
+    public void testSetup() throws SecurityException, IOException {
+        outputFile = Files.createTempFile(this.getClass().getSimpleName(), null);
+
+        handler = new FileHandler(outputFile.toString(), false);
+        handler.setFormatter(new SimpleFormatter());
+    }
+
+    @After
+    public void testTeardown() throws IOException {
+        Files.deleteIfExists(outputFile);
+    }
+}
diff --git a/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java b/src/test/java/org/lttng/ust/agent/benchmarks/jul/handler/builtin/NoHandlerBenchmark.java
new file mode 100644 (file)
index 0000000..953e5ba
--- /dev/null
@@ -0,0 +1,8 @@
+package org.lttng.ust.agent.benchmarks.jul.handler.builtin;
+
+import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
+
+public class NoHandlerBenchmark extends JulHandlerBenchmarkBase {
+
+    /* Do not setup any handler */
+}
index 18f84d3857d74b778942f0396617ab0a65484e54..62f7ec531eb12eba3bf837a1b89998b7b8a55e84 100644 (file)
@@ -6,12 +6,12 @@ import java.io.IOException;
 
 import org.junit.After;
 import org.junit.Before;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.LttngSession;
 import org.lttng.ust.agent.utils.LttngSession.Domain;
 
-public class LttngJulHandlerTracingDisabledBenchmark extends AbstractJulBenchmark {
+public class LttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase {
 
     private LttngSession session;
 
index 02c7b05ac138f5976c346743c18b045d370fee67..031c26e7c17a48b69ba5cc1c5ff5dce5ad61e895 100644 (file)
@@ -6,12 +6,12 @@ import java.io.IOException;
 
 import org.junit.After;
 import org.junit.Before;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.LttngSession;
 import org.lttng.ust.agent.utils.LttngSession.Domain;
 
-public class LttngJulHandlerTracingEnabledBenchmark extends AbstractJulBenchmark {
+public class LttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase {
 
     private LttngSession session;
 
index 2978fe00773a036a785901ea8485930978a425fd..275e33ded5d226f4c1dc84fb989c36ed78a8d0f3 100644 (file)
@@ -5,12 +5,12 @@ import static org.junit.Assert.assertTrue;
 import org.junit.After;
 import org.junit.Before;
 import org.lttng.ust.agent.LTTngAgent;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 import org.lttng.ust.agent.utils.LttngSession;
 import org.lttng.ust.agent.utils.LttngSession.Domain;
 
 @SuppressWarnings("deprecation")
-public class OldLttngJulHandlerTracingDisabledBenchmark extends AbstractJulBenchmark {
+public class OldLttngJulHandlerTracingDisabledBenchmark extends JulHandlerBenchmarkBase {
 
     private LttngSession session;
 
index c6cc49c5c1553994d6c267e9c6682f6cdb60fa0c..1e2ce4bbc95bd3957cbcc9ae2f3976e78495abad 100644 (file)
@@ -8,13 +8,13 @@ import java.lang.reflect.Field;
 import org.junit.After;
 import org.junit.Before;
 import org.lttng.ust.agent.LTTngAgent;
-import org.lttng.ust.agent.benchmarks.jul.handler.AbstractJulBenchmark;
+import org.lttng.ust.agent.benchmarks.jul.handler.JulHandlerBenchmarkBase;
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.utils.LttngSession;
 import org.lttng.ust.agent.utils.LttngSession.Domain;
 
 @SuppressWarnings("deprecation")
-public class OldLttngJulHandlerTracingEnabledBenchmark extends AbstractJulBenchmark {
+public class OldLttngJulHandlerTracingEnabledBenchmark extends JulHandlerBenchmarkBase {
 
     private LttngSession session;
     private LttngLogHandler agentHandler;
This page took 0.031657 seconds and 4 git commands to generate.