aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/etc/performance/dirscanner.xml
blob: 5628a46cc97587250aa24aa5e3583e7c5903eb93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<?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 or big-setup target.  Note that this will create
    a directory tree holding 10000 (setup) or 100000 (big-setup)
    directories and about 22000 (setup) or 222000 (big-setup) files.

    The setup/big-setup targets require Ant 1.7.0 or later.  It may be
    a good idea to use the -logfile option.

    Consider taking a nap if you run Ant 1.6.x or 1.7.0 against a
    "big" setup.

    If Ant 1.6.x is detected or the property ant16 has been specified
    on the command line then the tests will use the pathconvert task
    instead of resourcecount.  So if you want to compare Ant 1.6.x
    with later versions of you must specify ant16 on the command line
    during your 1.[78].x tests.

    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"/>

  <condition property="ant16">
    <contains string="${ant.version}" substring="1.6."/>
  </condition>

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

  <target name="prepare-setup">
    <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 {
    private boolean biggerSetup = false;

    public void setBig(boolean b) {
        biggerSetup = b;
    }

    public void execute() {
        Mkdir mkdir = new Mkdir();
        mkdir.bindToOwner(this);
        Touch touch = new Touch();
        touch.bindToOwner(this);
        String tmp = getProject().getProperty("test.dir");
        if (!biggerSetup) {
            createTree(new File(tmp), mkdir, touch);
        } else {
            for (int i = 0; i < 10; i++) {
                File f = new File(tmp, String.valueOf(i));
                createTree(f, mkdir, touch);
                mkfiles(touch, f);
            }
        }
    }

    private static void createTree(File root, Mkdir mkdir, Touch touch) {
        for (int i1 = 0; i1 < 10; i1++) {
            File f1 = new File(root, 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>
  </target>

  <target name="setup" description="Sets up the environment for tests"
          depends="prepare-setup">
   <setup/>
  </target>

  <target name="big-setup"
          description="Sets up the &quot;big&quot; environment for tests"
          depends="prepare-setup">
   <setup big="true"/>
  </target>

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

  <target name="define-scan-16" if="ant16">
    <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>

  <target name="define-scan-17+" unless="ant16">
    <macrodef name="scan">
      <attribute name="test"/>
      <element name="patterns" optional="true"/>
      <sequential>
        <resourcecount property="@{test}">
          <fileset dir="${test.dir}" followSymlinks="${symlinks}"
                   casesensitive="${casesensitive}">
            <patterns/>
          </fileset>
        </resourcecount>
      </sequential>
    </macrodef>
  </target>

  <target name="define-scan" depends="define-scan-16,define-scan-17+"/>

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

  <target name="roots"
          depends="define-scan"
          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="many-roots"
          depends="define-scan"
          description="only contains include patterns that match starts">
    <scan test="many-roots">
      <patterns>
        <include name="0/"/>
        <include name="0/0/"/>
        <include name="0/0/0/"/>
        <include name="0/0/0/0/"/>
        <include name="1/"/>
        <include name="1/1/"/>
        <include name="1/1/1/"/>
        <include name="1/1/1/1/"/>
        <include name="2/"/>
        <include name="2/2/"/>
        <include name="2/2/2/"/>
        <include name="2/2/2/2/"/>
        <include name="3/"/>
        <include name="3/3/"/>
        <include name="3/3/3/"/>
        <include name="3/3/3/3/"/>
        <include name="4/"/>
        <include name="4/4/"/>
        <include name="4/4/4/"/>
        <include name="4/4/4/4/"/>
        <include name="5/"/>
        <include name="5/5/"/>
        <include name="5/5/5/"/>
        <include name="5/5/5/5/"/>
        <include name="6/"/>
        <include name="6/6/"/>
        <include name="6/6/6/"/>
        <include name="6/6/6/6/"/>
        <include name="7/"/>
        <include name="7/7/"/>
        <include name="7/7/7/"/>
        <include name="7/7/7/7/"/>
        <include name="8/"/>
        <include name="8/8/"/>
        <include name="8/8/8/"/>
        <include name="8/8/8/8/"/>
        <include name="9/"/>
        <include name="9/9/"/>
        <include name="9/9/9/"/>
        <include name="9/9/9/9/"/>
      </patterns>
    </scan>
  </target>

  <target name="recursive-excludes"
          depends="define-scan"
          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"
          depends="define-scan"
          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"
          depends="define-scan"
          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="define-scan,matchall, roots, recursive-excludes, name-matches, many-patterns, many-roots"/>
</project>