aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/etc/performance/build.xml
blob: c3e3ed9ea15e4a71c9e8452a2dc17df4dc42d46b (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
<?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 default="all" xmlns:ac="antlib:net.sf.antcontrib">
  <description>
    This build file is designed to report the performance
    of ant from various releases.
    to use:
    * install ant-contrib.jar to ($ANT_HOME|$HOME/.ant)/lib
    * install beanshell jar and bsf jar
    * use unix (with bash) or install cygwin
    * set the env variables {whichever needs testing}
      ANT_HOME
      ANT_HOME_6_5 (the directory containing ant 1.6.5)
      ANT_HOME_6_4
      ANT_HOME_5_4
    
    * run ant
    For example:
       export ANT_HOME="c:/cygwin/home/me/svn/trunk/dist"
       export ANT_HOME_5_4="l:/apps/apache-ant-1.5.4"
       ant.bat

    TODO: more build files.
  </description>
  <property environment="env"/>

  <target name="all" depends="gen,do-times"/>

  <target name="clean">
    <delete quiet="yes" dir="build"/>
  </target>

  <macrodef name="run-ant-files">
    <attribute name="env-ant"/>
    <sequential>
      <ac:if>
        <isset property="@{env-ant}"/>
        <then>
          <ac:shellscript shell="bash">
            export ANT_HOME=${@{env-ant}}
            echo $ANT_HOME
            echo -n "--  props.xml     --: "
            $ANT_HOME/bin/ant -f build/gen/props.xml | grep time
            echo -n "-- ant-call.xml   --: "
            $ANT_HOME/bin/ant -f build/gen/ant-call.xml | grep time
          </ac:shellscript>
        </then>
      </ac:if>
    </sequential>
  </macrodef>
  
  <target name="do-times">
    <run-ant-files env-ant="env.ANT_HOME"/>
    <run-ant-files env-ant="env.ANT_HOME_6_5"/>
    <run-ant-files env-ant="env.ANT_HOME_6_2"/>
    <run-ant-files env-ant="env.ANT_HOME_5_4"/>
  </target>


  <target name="gen-dirs">
    <mkdir dir="build/gen"/>
  </target>

  <target name="avail">
    <available property="avail.props.xml"
               file="props.xml" filepath="build/gen"/>
    <available property="avail.ant-call.xml"
               file="ant-call.xml" filepath="build/gen"/>
  </target>

  <target name="gen-props" depends="gen-dirs,avail" unless="avail.props.xml">
    <script language="beanshell">
      import java.io.*;
      out = new PrintWriter(new BufferedWriter(new FileWriter(
          "build/gen/props.xml")));
      out.println("&lt;project name='props' default='props'&gt;");
      out.println("  &lt;target name='props'&gt;");
      for (int i = 0; i &lt; 20000; ++i) {
          out.println(
              "    &lt;property name='prop" + i + "' value='val'/&gt;");
      }
      out.println("  &lt;/target&gt;");
      out.println("&lt;/project&gt;");
      out.close();
      self.log("Created build/gen/props.xml");
    </script>
  </target>

  <target name="gen-ant-call" depends="gen-dirs,avail"
          unless="avail.ant-call.xml">
    <script language="beanshell">
      import java.io.*;
      out = new PrintWriter(new BufferedWriter(new FileWriter(
          "build/gen/ant-call.xml")));
      out.println("&lt;project name='ant-call' default='call'&gt;");
      out.println("  &lt;target name='me'/&gt;");
      out.println("  &lt;target name='call'&gt;");
      for (int i = 0; i &lt; 1000; ++i) {
          out.println("    &lt;antcall target='me'/&gt;");
      }
      out.println("  &lt;/target&gt;");
      out.println("&lt;/project&gt;");
      out.close();
      self.log("Created build/gen/ant-call.xml");
    </script>
  </target>

  <target name="gen" depends="gen-ant-call,gen-props"/>
</project>