b435e40fbfa514105414bc59bd780d69c888bb33
1 package org
.lttng
.ust
.tests
;
3 import java
.io
.IOException
;
4 import java
.util
.logging
.FileHandler
;
5 import java
.util
.logging
.Handler
;
6 import java
.util
.logging
.Level
;
7 import java
.util
.logging
.Logger
;
8 import java
.util
.logging
.SimpleFormatter
;
10 import org
.lttng
.ust
.LTTngUst
;
12 public class Benchmark
{
14 /** Nb of runs per test, result will be averaged */
15 private static final int NB_RUNS
= 5;
17 /** Trace/log events per run */
18 private static final int NB_ITER
= 1000000;
20 /** Which tests to run (for different number of threads) */
21 private static final int[] nbThreads
= {1, 1, 2, 3, 4, 5, 6, 7, 8};
23 private static Runner runner
;
24 private static Logger log
;
26 public static void main(String
[] args
) throws SecurityException
, IOException
{
30 /* Set up the logger */
31 log
= Logger
.getLogger("Test logger");
32 log
.setUseParentHandlers(false);
33 fh
= new FileHandler("/tmp/log", false);
34 fh
.setFormatter(new SimpleFormatter());
35 // log.addHandler(fh);
36 log
.setLevel(Level
.ALL
);
38 /* Set up the tracer */
40 System
.out
.println("Press a key to start.");
43 for (int i
: nbThreads
) {
49 private static void runTest(int nbThreads
) throws SecurityException
, IOException
{
50 long start
, end
, average
, total
= 0;
51 for (int i
= 0; i
< NB_RUNS
; i
++) {
52 runner
= new Runner(nbThreads
, NB_ITER
, log
);
54 start
= System
.nanoTime();
56 end
= System
.nanoTime();
58 total
+= (end
- start
);
60 average
= total
/ NB_RUNS
;
61 System
.out
.println(nbThreads
+ " threads, average = " + average
/ NB_ITER
+ " ns/event");
This page took 0.030921 seconds and 3 git commands to generate.