Browse Source

performance tests for DirectoryScanner

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@696612 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
a2516f47db
1 changed files with 204 additions and 0 deletions
  1. +204
    -0
      src/etc/performance/dirscanner.xml

+ 204
- 0
src/etc/performance/dirscanner.xml View File

@@ -0,0 +1,204 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="dirscanner">
<description>
Contains tests that measure the relative performance of Ant's
directory scanner. This is mainly used to compare performance
changes between Ant releases.

Before you run any tests, you need to set up the environment by
running the setup target. Note that this will create a directory
tree holding 10000 directories and about 22000 files.

The setup target requires Ant 1.7.0 or later.

The tests use the pathconvert task whose performance should be
dominated by directory scanner, they would use ressourcecount if
that had been available in Ant 1.6.5.

The tests will use the default settings of followsymlinks="true"
and casesensitive="true" unless those values get overwritten by
the properties symlinks and/or casesensitive on the command line.
</description>

<property name="test.dir" location="${java.io.tmpdir}/dirscan.prf"/>

<property name="symlinks" value="true"/>
<property name="casesensitive" value="true"/>

<echo>This is ${ant.version}</echo>

<target name="setup" description="Sets up the environment for tests">
<mkdir dir="${test.dir}/src/org/apache/tools/ant"/>
<mkdir dir="${test.dir}/dest"/>
<echo file="${test.dir}/src/org/apache/tools/ant/DirscannerSetup.java"
><![CDATA[
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.tools.ant;

import java.io.File;
import org.apache.tools.ant.taskdefs.Mkdir;
import org.apache.tools.ant.taskdefs.Touch;

public class DirscannerSetup extends Task {
public void execute() {
Mkdir mkdir = new Mkdir();
mkdir.bindToOwner(this);
Touch touch = new Touch();
touch.bindToOwner(this);
String tmp = getProject().getProperty("test.dir");
for (int i1 = 0; i1 < 10; i1++) {
File f1 = new File(tmp, String.valueOf(i1));
for (int i2 = 0; i2 < 10; i2++) {
File f2 = new File(f1, String.valueOf(i2));
for (int i3 = 0; i3 < 10; i3++) {
File f3 = new File(f2, String.valueOf(i3));
for (int i4 = 0; i4 < 10; i4++) {
File f4 = new File(f3, String.valueOf(i4));
mkdir.setDir(f4);
mkdir.execute();
mkfiles(touch, f4);
}
mkfiles(touch, f3);
}
mkfiles(touch, f2);
}
mkfiles(touch, f1);
}
}

private static void mkfiles(Touch touch, File dir) {
touch.setFile(new File(dir, "A.txt"));
touch.execute();
touch.setFile(new File(dir, "B.xml"));
touch.execute();
}
}]]></echo>
<javac srcdir="${test.dir}/src" destdir="${test.dir}/dest"/>
<taskdef name="setup"
classname="org.apache.tools.ant.DirscannerSetup">
<classpath>
<pathelement location="${test.dir}/dest"/>
</classpath>
</taskdef>
<setup/>
</target>

<target name="cleanup"
description="removes the tree generated by setup">
<delete dir="${test.dir}"/>
</target>

<macrodef name="scan">
<attribute name="test"/>
<element name="patterns" optional="true"/>
<sequential>
<pathconvert property="@{test}">
<path>
<fileset dir="${test.dir}" followSymlinks="${symlinks}"
casesensitive="${casesensitive}">
<patterns/>
</fileset>
</path>
</pathconvert>
</sequential>
</macrodef>

<target name="matchall"
description="doesn't specify any patterns">
<scan test="matchall"/>
</target>

<target name="roots"
description="only contains include patterns that match starts">
<scan test="roots">
<patterns>
<include name="1/2/3/**"/>
<include name="9/**"/>
</patterns>
</scan>
</target>

<target name="recursive-excludes"
description="specifies include and exclude patterns with wildcards">
<scan test="recursive-excludes">
<patterns>
<include name="**/5/**"/>
<exclude name="**/6/**"/>
</patterns>
</scan>
</target>

<target name="name-matches"
description="specifies include and exclude patterns matching on file names">
<scan test="names-matches">
<patterns>
<include name="**/*.txt"/>
<exclude name="**/4/**"/>
</patterns>
</scan>
</target>

<target name="many-patterns"
description="specifies many include and exclude patterns">
<scan test="many-patterns">
<patterns>
<include name="*/1/**"/>
<include name="*/3/**/1/**"/>
<include name="6/**"/>
<include name="**/*.xml"/>
<include name="**/4/*"/>
<include name="**/2*/**"/>
<include name="**/X/**"/>
<include name="8/9/4/2/B.xml"/>
<include name="9/*"/>
<include name="0/*/**"/>
<exclude name="*/5/**"/>
<exclude name="*/7/**/0/**"/>
<exclude name="1/**"/>
<exclude name="**/*.txt"/>
<exclude name="**/0/*"/>
<exclude name="**/8*/**"/>
<exclude name="**/Y/**"/>
<exclude name="8/9/4/2/A.txt"/>
<exclude name="3/*"/>
<exclude name="7/*/**"/>
</patterns>
</scan>
</target>

<target name="all"
depends="matchall, roots, recursive-excludes, name-matches, many-patterns"/>
</project>

Loading…
Cancel
Save