Initial commit
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 4 May 2012 04:51:39 +0000 (00:51 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 4 May 2012 04:51:39 +0000 (00:51 -0400)
.classpath [new file with mode: 0644]
.gitignore [new file with mode: 0644]
.project [new file with mode: 0644]
.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
src/org/lttng/ust/tests/Benchmark.java [new file with mode: 0644]
src/org/lttng/ust/tests/Runner.java [new file with mode: 0644]
src/org/lttng/ust/tests/Worker.java [new file with mode: 0644]

diff --git a/.classpath b/.classpath
new file mode 100644 (file)
index 0000000..1989a84
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+       <classpathentry kind="lib" path="/usr/share/java/liblttng-ust-java.jar">
+               <attributes>
+                       <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="/usr/local/lib"/>
+               </attributes>
+       </classpathentry>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..e660fd9
--- /dev/null
@@ -0,0 +1 @@
+bin/
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..b0299db
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>test</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..e388939
--- /dev/null
@@ -0,0 +1,12 @@
+#Thu May 03 13:20:10 EDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/src/org/lttng/ust/tests/Benchmark.java b/src/org/lttng/ust/tests/Benchmark.java
new file mode 100644 (file)
index 0000000..45000ac
--- /dev/null
@@ -0,0 +1,55 @@
+package org.lttng.ust.tests;
+
+import java.io.IOException;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
+
+import org.lttng.ust.LTTngUst;
+
+public class Benchmark {
+
+    private static final int NB_RUNS = 5;
+    private static final int NB_THREADS = 2;
+
+    /**
+     * @param args
+     * @throws IOException
+     * @throws SecurityException
+     */
+    public static void main(String[] args) throws SecurityException,
+            IOException {
+        Runner runner;
+        long start, end, average, total = 0;
+
+        final Logger log;
+        final FileHandler fh;
+
+        /* Set up the logger */
+        log = Logger.getLogger("Test logger");
+        log.setUseParentHandlers(false);
+        fh = new FileHandler("/tmp/log", false);
+        fh.setFormatter(new SimpleFormatter());
+        // log.addHandler(fh);
+        log.setLevel(Level.ALL);
+
+        /* Set up the tracer */
+        LTTngUst.init();
+        System.out.println("Press a key to start.");
+        System.in.read();
+
+        for (int i = 0; i < NB_RUNS; i++) {
+            runner = new Runner(NB_THREADS, log);
+
+            start = System.nanoTime();
+            runner.run();
+            end = System.nanoTime();
+
+            total += (end - start);
+        }
+        average = total / NB_RUNS;
+        System.out.println("Average = " + average / 1000000 + " ms");
+    }
+
+}
diff --git a/src/org/lttng/ust/tests/Runner.java b/src/org/lttng/ust/tests/Runner.java
new file mode 100644 (file)
index 0000000..f9a08ce
--- /dev/null
@@ -0,0 +1,47 @@
+package org.lttng.ust.tests;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.FileHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.logging.SimpleFormatter;
+
+public class Runner implements Runnable {
+
+    private final List<Worker> workers;
+    private final List<Thread> workerThreads;
+
+    public Runner(int nbThreads, Logger log) throws SecurityException,
+            IOException {
+        Worker curWorker;
+
+        workers = new LinkedList<>();
+        workerThreads = new LinkedList<>();
+
+        for (int i = 0; i < nbThreads; i++) {
+            curWorker = new Worker(i, log);
+            workers.add(curWorker);
+            workerThreads.add(new Thread(curWorker, "worker " + i));
+        }
+    }
+
+    @Override
+    public void run() {
+        // System.out.println("Starting");
+        for (Thread curThread : workerThreads) {
+            curThread.start();
+        }
+
+        for (Thread curThread : workerThreads) {
+            try {
+                curThread.join();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        // System.out.println("Finished");
+    }
+}
diff --git a/src/org/lttng/ust/tests/Worker.java b/src/org/lttng/ust/tests/Worker.java
new file mode 100644 (file)
index 0000000..e608ac3
--- /dev/null
@@ -0,0 +1,29 @@
+package org.lttng.ust.tests;
+
+import java.util.logging.Logger;
+
+import org.lttng.ust.LTTngUst;
+
+public class Worker implements Runnable {
+
+    private final Logger log;
+    private final int threadNumber;
+    private long curCount;
+
+    public Worker(int nb, Logger log) {
+        this.log = log;
+        threadNumber = nb;
+        curCount = 0;
+    }
+
+    @Override
+    public void run() {
+        for (int i = 0; i < 10000; i++) {
+            // log.info("Thread " + threadNumber + ", iteration " + i);
+            LTTngUst.tracepointIntInt("Thread/Iteration", threadNumber, i);
+            curCount += i;
+        }
+        // System.out.println(curCount);
+    }
+
+}
This page took 0.026021 seconds and 4 git commands to generate.