Commit | Line | Data |
---|---|---|
087a198a AM |
1 | package org.lttng.ust.tests; |
2 | ||
3 | import java.io.IOException; | |
4 | import java.util.logging.FileHandler; | |
5 | import java.util.logging.Level; | |
6 | import java.util.logging.Logger; | |
7 | import java.util.logging.SimpleFormatter; | |
8 | ||
9 | import org.lttng.ust.LTTngUst; | |
10 | ||
11 | public class Benchmark { | |
12 | ||
13 | private static final int NB_RUNS = 5; | |
14 | private static final int NB_THREADS = 2; | |
15 | ||
16 | /** | |
17 | * @param args | |
18 | * @throws IOException | |
19 | * @throws SecurityException | |
20 | */ | |
21 | public static void main(String[] args) throws SecurityException, | |
22 | IOException { | |
23 | Runner runner; | |
24 | long start, end, average, total = 0; | |
25 | ||
26 | final Logger log; | |
27 | final FileHandler fh; | |
28 | ||
29 | /* Set up the logger */ | |
30 | log = Logger.getLogger("Test logger"); | |
31 | log.setUseParentHandlers(false); | |
32 | fh = new FileHandler("/tmp/log", false); | |
33 | fh.setFormatter(new SimpleFormatter()); | |
34 | // log.addHandler(fh); | |
35 | log.setLevel(Level.ALL); | |
36 | ||
37 | /* Set up the tracer */ | |
38 | LTTngUst.init(); | |
39 | System.out.println("Press a key to start."); | |
40 | System.in.read(); | |
41 | ||
42 | for (int i = 0; i < NB_RUNS; i++) { | |
43 | runner = new Runner(NB_THREADS, log); | |
44 | ||
45 | start = System.nanoTime(); | |
46 | runner.run(); | |
47 | end = System.nanoTime(); | |
48 | ||
49 | total += (end - start); | |
50 | } | |
51 | average = total / NB_RUNS; | |
52 | System.out.println("Average = " + average / 1000000 + " ms"); | |
53 | } | |
54 | ||
55 | } |