[slf4j-dev] svn commit: r993 - in slf4j/trunk/slf4j-jdk14/src: main/java/org/slf4j/impl test/java/org/slf4j/impl
ceki at slf4j.org
ceki at slf4j.org
Tue Feb 26 19:20:52 CET 2008
Author: ceki
Date: Tue Feb 26 19:20:52 2008
New Revision: 993
Added:
slf4j/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java
Modified:
slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java
Log:
- Avoiding needless processing in slf4j-jdk14. This fixes bug 72
Modified: slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java
==============================================================================
--- slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java (original)
+++ slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/JDK14LoggerAdapter.java Tue Feb 26 19:20:52 2008
@@ -558,6 +558,10 @@
* @param t
*/
private void log(String callerFQCN, Level level, String msg, Throwable t) {
+ // avoid useless processing in case the level is disabled
+ //if(!logger.isLoggable(level)) {
+ // return;
+ //}
// millis and thread are filled by the constructor
LogRecord record = new LogRecord(level, msg);
record.setLoggerName(getName());
Added: slf4j/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java
==============================================================================
--- (empty file)
+++ slf4j/trunk/slf4j-jdk14/src/test/java/org/slf4j/impl/PerfTest.java Tue Feb 26 19:20:52 2008
@@ -0,0 +1,39 @@
+package org.slf4j.impl;
+
+import junit.framework.TestCase;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PerfTest extends TestCase {
+
+ public PerfTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void test() {
+ Logger logger = LoggerFactory.getLogger(PerfTest.class);
+ int len = 1000;
+ for (int i = 0; i < len; i++) {
+ logger.debug("hello");
+ }
+
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < len; i++) {
+ logger.debug("hello");
+ }
+
+ long end = System.currentTimeMillis();
+
+ System.out.println("Difference "+(end-start));
+ }
+
+}
More information about the slf4j-dev
mailing list