1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  
11  package ch.qos.logback.classic.multiJVM;
12  
13  import org.slf4j.Logger;
14  
15  public class LoggingThread extends Thread {
16    static String msgLong = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
17  
18    final long len;
19    final Logger logger;
20    private double durationPerLog;
21  
22    public LoggingThread(Logger logger, long len) {
23      this.logger = logger;
24      this.len = len;
25    }
26  
27    public void run() {
28      long before = System.nanoTime();
29      for (int i = 0; i < len; i++) {
30        logger.debug(msgLong + " " + i);
31  //      try {
32  //        Thread.sleep(100);
33  //      } catch (InterruptedException e) {
34  //      }
35      }
36      // in microseconds
37      durationPerLog = (System.nanoTime() - before) / (len * 1000.0);
38    }
39  
40    public double getDurationPerLogInMicroseconds() {
41      return durationPerLog;
42    }
43    
44    
45  }