[logback-dev] svn commit: r737 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/net test/java/ch/qos/logback/classic/net
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Sat Oct 21 18:47:57 CEST 2006
Author: ceki
Date: Sat Oct 21 18:47:57 2006
New Revision: 737
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java
Log:
Commit limited to lincesing or cosmetic changes
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java Sat Oct 21 18:47:57 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketNode.java Sat Oct 21 18:47:57 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/NOPOutputStream.java Sat Oct 21 18:47:57 2006
@@ -1,3 +1,13 @@
+/**
+ * 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.net;
import java.io.IOException;
@@ -5,10 +15,10 @@
public class NOPOutputStream extends OutputStream {
- @Override
- public void write(int b) throws IOException {
- // do nothing
+ @Override
+ public void write(int b) throws IOException {
+ // do nothing
- }
+ }
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SerializationPerfsTest.java Sat Oct 21 18:47:57 2006
@@ -11,177 +11,177 @@
public class SerializationPerfsTest extends TestCase {
- ObjectOutputStream oos;
+ ObjectOutputStream oos;
- int loopNumber = 10000;
- int resetFrequency = 100;
- int pauseFrequency = 10;
- long pauseLengthInMillis = 20;
-
- /**
- * <p>
- * Run the test with a MockSocketServer or with a NOPOutputStream
- * </p>
- * <p>
- * Run with external mock can be done using the ExternalMockSocketServer. It
- * needs to be launched from a separate JVM. The ExternalMockSocketServer does
- * not consume the events but passes through the available bytes that it is
- * recieving.
- * </p>
- * <p>
- * For example, with 4 test methods, you can launch the
- * ExternalMockSocketServer this way:
- * </p>
- * <p>
- * <code>java ch.qos.logback.classic.net.ExternalMockSocketServer 4</code>
- * </p>
- */
- boolean runWithExternalMockServer = true;
-
- /**
- * Last results:
- * Data sent mesured in kilobytes.
- * Avg time mesured in microsecs.
- *
- * NOPOutputStream:
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | | |
- * | MinimalObj Ser | 10000 | | |
- * | LoggEvent Ext | 10000 | | |
- * | LoggEvent Ser | 10000 | | |
- *
- * External MockServer with 45 letters-long message: on localhost
- * (always the same message)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | - | - |
- * | MinimalObj Ser | 10000 | 74 | 248 |
- * | LoggEvent Ext | 10000 | - | - |
- * | LoggEvent Ser | 10000 | 156 | 835 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- * External MockServer with 45 letters-long message: on localhost
- * (different message each time)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | | |
- * | MinimalObj Ser | 10000 | 73 | 1139 |
- * | LoggEvent Ext | 10000 | | |
- * | LoggEvent Ser | 10000 | 162 | 1752 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- * External MockServer with 45 letters-long message: on PIXIE
- * (always the same message)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | - | - |
- * | MinimalObj Ser | 10000 | 29 | 248 |
- * | LoggEvent Ext | 10000 | - | - |
- * | LoggEvent Ser | 10000 | 42 | 835 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- * External MockServer with 45 letters-long message: on PIXIE
- * (different message each time)
- * | | Runs | Avg time | Data sent |
- * | MinimalObj Ext | 10000 | | |
- * | MinimalObj Ser | 10000 | 27 | 1139 |
- * | LoggEvent Ext | 10000 | | |
- * | LoggEvent Ser | 10000 | 44 | 1752 |
- * pauseFrequency = 10 and pauseLengthInMillis = 20
- *
- */
-
- public void setUp() throws Exception {
- super.setUp();
- if (runWithExternalMockServer) {
- oos = new ObjectOutputStream(new Socket("pixie",
- ExternalMockSocketServer.PORT).getOutputStream());
- } else {
- oos = new ObjectOutputStream(new NOPOutputStream());
- }
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- oos.close();
- oos = null;
- }
-
- public void runPerfTest(Builder builder, String label) throws Exception {
- // long time1 = System.nanoTime();
-
- // Object builtObject = builder.build(1);
-
- // first run for just in time compiler
- int resetCounter = 0;
- int pauseCounter = 0;
- for (int i = 0; i < loopNumber; i++) {
- try {
- oos.writeObject(builder.build(i));
- oos.flush();
- if (++resetCounter >= resetFrequency) {
- oos.reset();
- resetCounter = 0;
- }
- if (++pauseCounter >= pauseFrequency) {
- Thread.sleep(pauseLengthInMillis);
- pauseCounter = 0;
- }
-
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
-
- // second run
- Long t1;
- Long t2;
- Long total = 0L;
- resetCounter = 0;
- pauseCounter = 0;
- // System.out.println("Beginning mesured run");
- for (int i = 0; i < loopNumber; i++) {
- try {
- t1 = System.nanoTime();
- oos.writeObject(builder.build(i));
- oos.flush();
- t2 = System.nanoTime();
- total += (t2 - t1);
- if (++resetCounter >= resetFrequency) {
- oos.reset();
- resetCounter = 0;
- }
- if (++pauseCounter >= pauseFrequency) {
- Thread.sleep(pauseLengthInMillis);
- pauseCounter = 0;
- }
- } catch (IOException ex) {
- fail(ex.getMessage());
- }
- }
- total /= 1000;
- System.out.println(label + " : average time = " + total / loopNumber
- + " microsecs after " + loopNumber + " writes.");
-
- // long time2 = System.nanoTime();
- // System.out.println("********* -> Time needed to run the test method: " +
- // Long.toString(time2-time1));
- }
-
-// public void testWithMinimalExternalization() throws Exception {
-// Builder builder = new MinimalExtBuilder();
-// runPerfTest(builder, "Minimal object externalization");
-// }
-
- public void testWithMinimalSerialization() throws Exception {
- Builder builder = new MinimalSerBuilder();
- runPerfTest(builder, "Minimal object serialization");
- }
-
-// public void testWithExternalization() throws Exception {
-// Builder builder = new LoggingEventExtBuilder();
-// runPerfTest(builder, "LoggingEvent object externalization");
-// }
-
- public void testWithSerialization() throws Exception {
- Builder builder = new LoggingEventBuilder();
- runPerfTest(builder, "LoggingEvent object serialization");
- }
+ int loopNumber = 10000;
+ int resetFrequency = 100;
+ int pauseFrequency = 10;
+ long pauseLengthInMillis = 20;
+
+ /**
+ * <p>
+ * Run the test with a MockSocketServer or with a NOPOutputStream
+ * </p>
+ * <p>
+ * Run with external mock can be done using the ExternalMockSocketServer. It
+ * needs to be launched from a separate JVM. The ExternalMockSocketServer does
+ * not consume the events but passes through the available bytes that it is
+ * recieving.
+ * </p>
+ * <p>
+ * For example, with 4 test methods, you can launch the
+ * ExternalMockSocketServer this way:
+ * </p>
+ * <p>
+ * <code>java ch.qos.logback.classic.net.ExternalMockSocketServer 4</code>
+ * </p>
+ */
+ boolean runWithExternalMockServer = true;
+
+ /**
+ * Last results:
+ * Data sent mesured in kilobytes.
+ * Avg time mesured in microsecs.
+ *
+ * NOPOutputStream:
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | | |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | | |
+ *
+ * External MockServer with 45 letters-long message: on localhost
+ * (always the same message)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | - | - |
+ * | MinimalObj Ser | 10000 | 74 | 248 |
+ * | LoggEvent Ext | 10000 | - | - |
+ * | LoggEvent Ser | 10000 | 156 | 835 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ * External MockServer with 45 letters-long message: on localhost
+ * (different message each time)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | 73 | 1139 |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | 162 | 1752 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ * External MockServer with 45 letters-long message: on PIXIE
+ * (always the same message)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | - | - |
+ * | MinimalObj Ser | 10000 | 29 | 248 |
+ * | LoggEvent Ext | 10000 | - | - |
+ * | LoggEvent Ser | 10000 | 42 | 835 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ * External MockServer with 45 letters-long message: on PIXIE
+ * (different message each time)
+ * | | Runs | Avg time | Data sent |
+ * | MinimalObj Ext | 10000 | | |
+ * | MinimalObj Ser | 10000 | 27 | 1139 |
+ * | LoggEvent Ext | 10000 | | |
+ * | LoggEvent Ser | 10000 | 44 | 1752 |
+ * pauseFrequency = 10 and pauseLengthInMillis = 20
+ *
+ */
+
+ public void setUp() throws Exception {
+ super.setUp();
+ if (runWithExternalMockServer) {
+ oos = new ObjectOutputStream(new Socket("pixie",
+ ExternalMockSocketServer.PORT).getOutputStream());
+ } else {
+ oos = new ObjectOutputStream(new NOPOutputStream());
+ }
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ oos.close();
+ oos = null;
+ }
+
+ public void runPerfTest(Builder builder, String label) throws Exception {
+ // long time1 = System.nanoTime();
+
+ // Object builtObject = builder.build(1);
+
+ // first run for just in time compiler
+ int resetCounter = 0;
+ int pauseCounter = 0;
+ for (int i = 0; i < loopNumber; i++) {
+ try {
+ oos.writeObject(builder.build(i));
+ oos.flush();
+ if (++resetCounter >= resetFrequency) {
+ oos.reset();
+ resetCounter = 0;
+ }
+ if (++pauseCounter >= pauseFrequency) {
+ Thread.sleep(pauseLengthInMillis);
+ pauseCounter = 0;
+ }
+
+ } catch (IOException ex) {
+ fail(ex.getMessage());
+ }
+ }
+
+ // second run
+ Long t1;
+ Long t2;
+ Long total = 0L;
+ resetCounter = 0;
+ pauseCounter = 0;
+ // System.out.println("Beginning mesured run");
+ for (int i = 0; i < loopNumber; i++) {
+ try {
+ t1 = System.nanoTime();
+ oos.writeObject(builder.build(i));
+ oos.flush();
+ t2 = System.nanoTime();
+ total += (t2 - t1);
+ if (++resetCounter >= resetFrequency) {
+ oos.reset();
+ resetCounter = 0;
+ }
+ if (++pauseCounter >= pauseFrequency) {
+ Thread.sleep(pauseLengthInMillis);
+ pauseCounter = 0;
+ }
+ } catch (IOException ex) {
+ fail(ex.getMessage());
+ }
+ }
+ total /= 1000;
+ System.out.println(label + " : average time = " + total / loopNumber
+ + " microsecs after " + loopNumber + " writes.");
+
+ // long time2 = System.nanoTime();
+ // System.out.println("********* -> Time needed to run the test method: " +
+ // Long.toString(time2-time1));
+ }
+
+ // public void testWithMinimalExternalization() throws Exception {
+ // Builder builder = new MinimalExtBuilder();
+ // runPerfTest(builder, "Minimal object externalization");
+ // }
+
+ public void testWithMinimalSerialization() throws Exception {
+ Builder builder = new MinimalSerBuilder();
+ runPerfTest(builder, "Minimal object serialization");
+ }
+
+ // public void testWithExternalization() throws Exception {
+ // Builder builder = new LoggingEventExtBuilder();
+ // runPerfTest(builder, "LoggingEvent object externalization");
+ // }
+
+ public void testWithSerialization() throws Exception {
+ Builder builder = new LoggingEventBuilder();
+ runPerfTest(builder, "LoggingEvent object serialization");
+ }
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java Sat Oct 21 18:47:57 2006
@@ -1,3 +1,12 @@
+/**
+ * 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.net;
import java.util.Map;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java Sat Oct 21 18:47:57 2006
@@ -1,5 +1,5 @@
/**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -20,86 +20,86 @@
public class SocketMin {
- static Logger logger = (Logger) LoggerFactory.getLogger(SocketMin.class
- .getName());
- static SocketAppender s;
-
- public static void main(String argv[]) {
- if (argv.length == 3) {
- init(argv[0], argv[1]);
- } else {
- usage("Wrong number of arguments.");
- }
-
- // NDC.push("some context");
- if (argv[2].equals("true")) {
- loop();
- } else {
- test();
- }
-
- s.stop();
- }
-
- static void usage(String msg) {
- System.err.println(msg);
- System.err.println("Usage: java " + SocketMin.class
- + " host port true|false");
- System.exit(1);
- }
-
- static void init(String host, String portStr) {
- Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
- BasicConfigurator.configure(root.getLoggerContext());
- try {
- int port = Integer.parseInt(portStr);
- logger.info("Creating socket appender (" + host + "," + port + ").");
- s = new SocketAppender(host, port);
- s.setName("S");
- root.addAppender(s);
- } catch (java.lang.NumberFormatException e) {
- e.printStackTrace();
- usage("Could not interpret port number [" + portStr + "].");
- } catch (Exception e) {
- System.err.println("Could not start!");
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- static void loop() {
- Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
- InputStreamReader in = new InputStreamReader(System.in);
- System.out.println("Type 'q' to quit");
- int i;
- int k = 0;
- while (true) {
- logger.debug("Message " + k++);
- logger.info("Message " + k++);
- logger.warn("Message " + k++);
- logger.error("Message " + k++, new Exception("Just testing"));
- try {
- i = in.read();
- } catch (Exception e) {
- return;
- }
- if (i == -1)
- break;
- if (i == 'q')
- break;
- if (i == 'r') {
- System.out.println("Removing appender S");
- root.detachAppender("S");
- }
- }
- }
-
- static void test() {
- int i = 0;
- logger.debug("Message " + i++);
- logger.info("Message " + i++);
- logger.warn("Message " + i++);
- logger.error("Message " + i++);
- logger.debug("Message " + i++, new Exception("Just testing."));
- }
+ static Logger logger = (Logger) LoggerFactory.getLogger(SocketMin.class
+ .getName());
+ static SocketAppender s;
+
+ public static void main(String argv[]) {
+ if (argv.length == 3) {
+ init(argv[0], argv[1]);
+ } else {
+ usage("Wrong number of arguments.");
+ }
+
+ // NDC.push("some context");
+ if (argv[2].equals("true")) {
+ loop();
+ } else {
+ test();
+ }
+
+ s.stop();
+ }
+
+ static void usage(String msg) {
+ System.err.println(msg);
+ System.err.println("Usage: java " + SocketMin.class
+ + " host port true|false");
+ System.exit(1);
+ }
+
+ static void init(String host, String portStr) {
+ Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
+ BasicConfigurator.configure(root.getLoggerContext());
+ try {
+ int port = Integer.parseInt(portStr);
+ logger.info("Creating socket appender (" + host + "," + port + ").");
+ s = new SocketAppender(host, port);
+ s.setName("S");
+ root.addAppender(s);
+ } catch (java.lang.NumberFormatException e) {
+ e.printStackTrace();
+ usage("Could not interpret port number [" + portStr + "].");
+ } catch (Exception e) {
+ System.err.println("Could not start!");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ static void loop() {
+ Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
+ InputStreamReader in = new InputStreamReader(System.in);
+ System.out.println("Type 'q' to quit");
+ int i;
+ int k = 0;
+ while (true) {
+ logger.debug("Message " + k++);
+ logger.info("Message " + k++);
+ logger.warn("Message " + k++);
+ logger.error("Message " + k++, new Exception("Just testing"));
+ try {
+ i = in.read();
+ } catch (Exception e) {
+ return;
+ }
+ if (i == -1)
+ break;
+ if (i == 'q')
+ break;
+ if (i == 'r') {
+ System.out.println("Removing appender S");
+ root.detachAppender("S");
+ }
+ }
+ }
+
+ static void test() {
+ int i = 0;
+ logger.debug("Message " + i++);
+ logger.info("Message " + i++);
+ logger.warn("Message " + i++);
+ logger.error("Message " + i++);
+ logger.debug("Message " + i++, new Exception("Just testing."));
+ }
}
More information about the logback-dev
mailing list