Author: brett
Date: Tue Mar 2 13:28:10 2010
New Revision: 918026
URL: http://svn.apache.org/viewvc?rev=918026&view=rev
Log:
[MRM-589] add some more notes and add back the ant scanner test
Modified:
archiva/sandbox/archiva-scanner-performance/pom.xml
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java
Modified: archiva/sandbox/archiva-scanner-performance/pom.xml
URL:
http://svn.apache.org/viewvc/archiva/sandbox/archiva-scanner-performance/pom.xml?rev=918026&r1=918025&r2=918026&view=diff
==============================================================================
--- archiva/sandbox/archiva-scanner-performance/pom.xml (original)
+++ archiva/sandbox/archiva-scanner-performance/pom.xml Tue Mar 2 13:28:10 2010
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-scanner-performance</artifactId>
@@ -12,12 +12,11 @@
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>
- <!--
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.0</version>
- </dependency>-->
+ </dependency>
</dependencies>
<profiles>
<profile>
Modified:
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java
URL:
http://svn.apache.org/viewvc/archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java?rev=918026&r1=918025&r2=918026&view=diff
==============================================================================
---
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java
(original)
+++
archiva/sandbox/archiva-scanner-performance/src/main/java/org/apache/archiva/App.java
Tue Mar 2 13:28:10 2010
@@ -7,6 +7,7 @@
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
+import org.apache.tools.ant.DirectoryScanner;
import java.io.File;
import java.io.FileFilter;
@@ -19,6 +20,10 @@
/**
* Hello world!
+ *
+ * Note: run with -XX:NewSize=1024m to get accurate values for "used memory"
You need to avoid any GC during the method,
+ * which can be monitored with -verbose:gc. Even without the NewSize, watching
the quantity of GC gives a reasonable
+ * expectation of memory use.
*/
public class App
{
@@ -30,11 +35,14 @@
throws RepositoryScannerException, IOException, InterruptedException
{
File basedir = args.length > 0 ? new File( args[0] ) : new File(
System.getProperty( "user.home" ),
-
"Library/Application Support/Archiva/data/repositories/internal" );
+
".m2/repository" );
gc();
-// System.out.println( "ant scanner" );
-// scanUsingAntScanner( basedir );
+ Thread.sleep( 3000 ); // help get accurate retained size
+
+ // note first call has a disadvantage due to disk caching
+ System.out.println( "ant scanner" );
+ scanUsingAntScanner( basedir );
System.out.println( "plexus-utils walker" );
scanUsingUtilsWalker( basedir );
System.out.println( "new walker" );
@@ -54,26 +62,26 @@
long start = System.currentTimeMillis();
MyDirectoryWalker walker = new MyDirectoryWalker( basedir, EXCLUDES );
walker.scan();
- System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ printTime( start );
showFreeMemory( startMemory );
System.out.println( "Files: " + walker.getCount() );
}
-// private static void scanUsingAntScanner( File basedir )
-// throws InterruptedException
-// {
-// long startMemory = getUsedMemory();
-// long start = System.currentTimeMillis();
-//
-// DirectoryScanner scanner = new DirectoryScanner();
-// scanner.setBasedir( basedir );
-// scanner.setIncludes( new String[]{"**/*"} );
-// scanner.setExcludes( EXCLUDES.toArray( new String[EXCLUDES.size()] )
);
-// scanner.scan();
-// System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
-// showFreeMemory( startMemory );
-// System.out.println( "Files: " + scanner.getIncludedFiles().length );
-// }
+ private static void scanUsingAntScanner( File basedir )
+ throws InterruptedException
+ {
+ long startMemory = getUsedMemory();
+ long start = System.currentTimeMillis();
+
+ DirectoryScanner scanner = new DirectoryScanner();
+ scanner.setBasedir( basedir );
+ scanner.setIncludes( new String[]{"**/*"} );
+ scanner.setExcludes( EXCLUDES.toArray( new String[EXCLUDES.size()] ) );
+ scanner.scan();
+ printTime( start );
+ showFreeMemory( startMemory );
+ System.out.println( "Files: " + scanner.getIncludedFiles().length );
+ }
private static void scanUsingUtilsScanner( File basedir )
throws InterruptedException
@@ -86,7 +94,7 @@
scanner.setIncludes( new String[]{"**/*"} );
scanner.setExcludes( EXCLUDES.toArray( new String[EXCLUDES.size()] ) );
scanner.scan();
- System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ printTime( start );
showFreeMemory( startMemory );
System.out.println( "Files: " + scanner.getIncludedFiles().length );
}
@@ -98,12 +106,11 @@
long start = System.currentTimeMillis();
org.codehaus.plexus.util.DirectoryWalker walker = new
org.codehaus.plexus.util.DirectoryWalker();
walker.setBaseDir( basedir );
-// walker.setIncludes( Collections.singletonList( "**/*" ) );
walker.setExcludes( EXCLUDES );
PlexusUtilsDirectoryWalkListener walkListener = new
PlexusUtilsDirectoryWalkListener();
walker.addDirectoryWalkListener( walkListener );
walker.scan();
- System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ printTime( start );
showFreeMemory( startMemory );
System.out.println( "Files: " + walkListener.getCount() );
}
@@ -115,12 +122,11 @@
long start = System.currentTimeMillis();
DirectoryWalker walker = new DirectoryWalker();
walker.setBaseDir( basedir );
-// walker.setIncludes( Collections.singletonList( "**/*" ) );
walker.setExcludes( EXCLUDES );
MyDirectoryWalkListener walkListener = new MyDirectoryWalkListener();
walker.addDirectoryWalkListener( walkListener );
walker.scan();
- System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ printTime( start );
showFreeMemory( startMemory );
System.out.println( "Files: " + walkListener.getCount() );
}
@@ -138,11 +144,16 @@
Collections.<InvalidRepositoryContentConsumer>emptyList(),
EXCLUDES,
RepositoryScanner.FRESH_SCAN );
- System.out.println( ( System.currentTimeMillis() - start ) + " ms" );
+ printTime( start );
showFreeMemory( startMemory );
System.out.println( stats.toDump( config ) );
}
+ private static void printTime( long start )
+ {
+ System.out.print( ( System.currentTimeMillis() - start ) + " ms; " );
+ }
+
private static long getUsedMemory()
throws InterruptedException
{
@@ -153,16 +164,15 @@
private static void showFreeMemory( long startMemory )
throws InterruptedException
{
- System.out.println( "used memory ~" + ( RUNTIME.totalMemory() -
RUNTIME.freeMemory() - startMemory ) );
+ long used = RUNTIME.totalMemory() - RUNTIME.freeMemory() - startMemory;
long endMemory = getUsedMemory();
- System.out.println( "retained memory ~" + ( endMemory - startMemory )
);
+ System.out.print( "retained memory ~" + ( endMemory - startMemory ) +
"; (used ~" + used + "); " );
}
private static void gc()
throws InterruptedException
{
System.gc();
- Thread.sleep( 3000 );
}
private static final class MyDirectoryWalker