logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/tests/src/java/org/apache/log4j/performance build.xml Loop.java
Date Mon, 06 Sep 2004 15:39:54 GMT
ceki        2004/09/06 08:39:54

  Modified:    tests/src/java/org/apache/log4j/performance build.xml
                        Loop.java
  Log:
  Work in progress.
  
  Revision  Changes    Path
  1.2       +9 -18     logging-log4j/tests/src/java/org/apache/log4j/performance/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/performance/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	6 Sep 2004 14:47:24 -0000	1.1
  +++ build.xml	6 Sep 2004 15:39:54 -0000	1.2
  @@ -1,12 +1,6 @@
  -<!-- This build file is intended to be launched from $LOG4J_HOME/tests -->
  -
  -	<project name="log4j-tests" default="usage" basedir="." >
  -
  -  <property file="build.properties"/>
  -  
  -	
  -  <!-- The base directory relative to which most targets are built -->
  -  <property name="base" value="."/>
  +<!-- This build file is intended to be launched from $LOG4J_HOME/tests 
  +     which is six levels up from the build file -->
  +<project name="log4j-tests" default="usage" basedir="../../../../../../" >
    
     <!-- The directory where source files are stored. -->
   	
  @@ -15,8 +9,8 @@
     <property name="examples.classes" value="../examples/classes/"/>
     <property name="tests.source.home" value="${base}/tests/src/java/"/>
   
  -  <property name="longrun" value="1000000"/>
  -  <property name="shortrun" value="10000"/>
  +  <property name="longrun"  value="100000"/>
  +  <property name="shortrun" value="20000"/>
   
     <path id="perf.classpath">
       <pathelement location="${project.source.home}"/>
  @@ -37,8 +31,9 @@
   	  </target>
   		
   	<target name="loop">
  +	    <echo message="Pattern is ${pattern}"/> 	
   		<java classname="org.apache.log4j.performance.Loop" 
  -			  fork="yes" failonerror="yes">
  +			  fork="yes" failonerror="true">
   			<classpath refid="perf.classpath"/>
   			<sysproperty key="pattern" value="${pattern}"/>
   			<arg line="${runLen} ${configFile}"/>
  @@ -46,11 +41,10 @@
   	</target>
   
    	<target name="null-loop">
  - 	  <echo message="Pattern is ${pattern}"/> 	
         <antcall target="loop">
      	    <param name="pattern" value="${pattern}"/>
      	    <param name="runLen" value="${longrun}"/>
  - 	    <param name="configFile" value="input/performance/null-appender1.xml"/>
  + 	    <param name="configFile" value="input/performance/null-appender.xml"/>
        </antcall>
   	</target>	
   		
  @@ -59,14 +53,11 @@
   	  <antcall target="loop">
   	  <param name="pattern" value="${pattern}"/>
   	  <param name="runLen" value="${shortrun}"/>
  -	  <param name="configFile" value="input/performance/null-appender.xml"/>
  +	  <param name="configFile" value="input\\performance\\null-appender.xml"/>
   	 </antcall>
   	</target>		
   		
   	<target name="null">
  -		 <antcall target="null-loop">
  -		   <param name="pattern" value=""/>
  -		 </antcall>
   		 <antcall target="null-loop">
   		   <param name="pattern" value="%p - %m%n"/>
   		 </antcall>
  
  
  
  1.2       +19 -3     logging-log4j/tests/src/java/org/apache/log4j/performance/Loop.java
  
  Index: Loop.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/performance/Loop.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Loop.java	6 Sep 2004 14:47:24 -0000	1.1
  +++ Loop.java	6 Sep 2004 15:39:54 -0000	1.2
  @@ -16,8 +16,13 @@
   
   package org.apache.log4j.performance;
   
  +import org.apache.log4j.Appender;
  +import org.apache.log4j.ConsoleAppender;
  +import org.apache.log4j.Layout;
  +import org.apache.log4j.Level;
   import org.apache.log4j.LogManager;
   import org.apache.log4j.Logger;
  +import org.apache.log4j.PatternLayout;
   import org.apache.log4j.joran.JoranConfigurator;
   
   /**
  @@ -32,12 +37,23 @@
     final static Logger logger = Logger.getLogger(Loop.class);
   
     public static void main(String[] args) throws Exception {
  +    
  +    Logger j = Logger.getLogger("org.apache.log4j.joran");
  +    j.setAdditivity(false);
  +    j.setLevel(Level.WARN);
  +    ConsoleAppender a = new ConsoleAppender();
  +    a.setLayout(new PatternLayout("%d %level %c - %m%n"));
  +    a.setName("console");
  +    a.activateOptions();
  +    j.addAppender(a);
  +    
       if (args.length == 2)
         init(args[0], args[1]);
       else
         usage("Wrong number of arguments.");
   
  -    long res = loop(logger, "Some fix message of medium length.");
  +    loop(1000, logger, "Some fix message of medium length.");
  +    long res = loop(runLength, logger, "Some fix message of medium length.");
       double average = (res * 1000.0) / runLength;
       System.out.println("Loop completed in [" + res + "] milliseconds, or ["
           + average + "] microseconds per log.");
  @@ -60,9 +76,9 @@
       jc.doConfigure(configFile, LogManager.getLoggerRepository());
     }
   
  -  static long loop(Logger logger, String msg) {
  +  static long loop(long len, Logger logger, String msg) {
       long before = System.currentTimeMillis();
  -    for (int i = 0; i < runLength; i++) {
  +    for (int i = 0; i < len; i++) {
         logger.debug(msg);
       }
       return (System.currentTimeMillis() - before);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message