[logback-dev] svn commit: r835 - logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Oct 31 22:42:26 CET 2006


Author: ceki
Date: Tue Oct 31 22:42:26 2006
New Revision: 835

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java

Log:
minor

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/BasicLoggerTest.java	Tue Oct 31 22:42:26 2006
@@ -1,11 +1,11 @@
 /**
- * Logback: the reliable, generic, fast and flexible logging framework.
- *
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
  * Copyright (C) 1999-2006, QOS.ch
- *
- * This library is free software, you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
  */
 package ch.qos.logback.classic;
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerPerfTest.java	Tue Oct 31 22:42:26 2006
@@ -1,9 +1,19 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ * 
+ * Copyright (C) 1999-2006, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
 package ch.qos.logback.classic;
 
 
 import java.net.InetAddress;
 
 import junit.framework.TestCase;
+import ch.qos.logback.classic.turbo.NOPClassicFilter;
 import ch.qos.logback.core.appender.NOPAppender;
 
 public class LoggerPerfTest extends TestCase {
@@ -16,8 +26,8 @@
   }
   public void testSpeed() {
     long len = 1000*1000*10;
-    loop(len);
-    double avg = loop(len);
+    loopBasic(len);
+    double avg = loopBasic(len);
     
     System.out.println("Running on "+localhostName);
     // check for performance on KAL only
@@ -27,10 +37,40 @@
     System.out.println("Average log time for disabled statements: "+avg+" nanos.");
   }
   
-  double loop(long len) {
+  public void testNOPFilterSpeed() {
+    long len = 1000*1000*10;
+    loopNopFilter(len);
+    double avg = loopNopFilter(len);
+    
+    System.out.println("Running on "+localhostName);
+    // check for performance on KAL only
+    if(KAL.equals(localhostName)) {
+      assertTrue(62 > avg);
+    }
+    System.out.println("Average log time for disabled statements: "+avg+" nanos.");
+  }
+  
+  double loopBasic(long len) {
+    LoggerContext lc = new LoggerContext();
+    NOPAppender mopAppender = new NOPAppender();
+    mopAppender.start();
+    Logger logger = lc.getLogger(this.getClass());
+    logger.setLevel(Level.OFF);
+    long start = System.nanoTime();
+    for(long i = 0; i < len; i++) {
+      logger.debug("Toto");
+    }
+    long end = System.nanoTime();
+    return (end-start)/len;
+  }
+  
+  double loopNopFilter(long len) {
     LoggerContext lc = new LoggerContext();
     NOPAppender mopAppender = new NOPAppender();
+    NOPClassicFilter nopFilter = new NOPClassicFilter();
+    nopFilter.setName("nop");
     mopAppender.start();
+    lc.addFilter(nopFilter);
     Logger logger = lc.getLogger(this.getClass());
     logger.setLevel(Level.OFF);
     long start = System.nanoTime();



More information about the logback-dev mailing list