001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.classic.multiJVM; 015 016import org.slf4j.Logger; 017 018public class LoggingThread extends Thread { 019 static String msgLong = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; 020 021 final long len; 022 final Logger logger; 023 private double durationPerLog; 024 025 public LoggingThread(Logger logger, long len) { 026 this.logger = logger; 027 this.len = len; 028 } 029 030 public void run() { 031 long before = System.nanoTime(); 032 for (int i = 0; i < len; i++) { 033 logger.debug(msgLong + " " + i); 034 // try { 035 // Thread.sleep(100); 036 // } catch (InterruptedException e) { 037 // } 038 } 039 // in microseconds 040 durationPerLog = (System.nanoTime() - before) / (len * 1000.0); 041 } 042 043 public double getDurationPerLogInMicroseconds() { 044 return durationPerLog; 045 } 046 047}