1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.multiJVM;
15
16 import org.slf4j.Logger;
17
18 public class LoggingThread extends Thread {
19 static String msgLong = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
20
21 final long len;
22 final Logger logger;
23 private double durationPerLog;
24
25 public LoggingThread(Logger logger, long len) {
26 this.logger = logger;
27 this.len = len;
28 }
29
30 public void run() {
31 long before = System.nanoTime();
32 for (int i = 0; i < len; i++) {
33 logger.debug(msgLong + " " + i);
34
35
36
37
38 }
39
40 durationPerLog = (System.nanoTime() - before) / (len * 1000.0);
41 }
42
43 public double getDurationPerLogInMicroseconds() {
44 return durationPerLog;
45 }
46
47 }