You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.xml 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <?xml version="1.0"?>
  2. <!--
  3. Copyright 2006 contributors.
  4. All rights reserved.
  5. This program and the accompanying materials are made available
  6. under the terms of the Eclipse Public License v 2.0
  7. which accompanies this distribution and is available at
  8. https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  9. Contributors: Adrian Colyer
  10. -->
  11. <project name="aspectj-profiling" default="usage">
  12. <!-- project.properties contains your local settings, not checked into CVS -->
  13. <property file="project.properties"/>
  14. <!-- default property settings, version controlled -->
  15. <property file="build.properties"/>
  16. <!-- pull in the ant file defining the paths etc. for the target application -->
  17. <import file="${target.application.definitions.file}"/>
  18. <!-- list of useful targets... -->
  19. <target name="usage">
  20. <echo message="ant build script for profiling AspectJ compiler"/>
  21. <echo message="useful targets are:"/>
  22. <echo message=" gc.suite : runs basic timing and gc for source, binary, ltw, and ajdt compiles"/>
  23. <echo message=" full.profile.suite : runs full profiling for source, binary, ltw, and ajdt compiles"/>
  24. <echo message=" source.compile : compiles from source (and weaves) with full profiling"/>
  25. <echo message=" source.compile.gc : compiles from source (and weaves) with basic timing and gc"/>
  26. <echo message=" binary.weave : binary weaving from injars and aspectpath with full profiling"/>
  27. <echo message=" binary.weave.gc : binary weaving from injars and aspectpath with basic timing and gc"/>
  28. <echo message=" loadtime.weave : load-time weaving with full profiling"/>
  29. <echo message=" loadtime.weave.gc : load-time weaving with basic timing and gc"/>
  30. <echo message=" ajdt.compile : source compile simulating ajdt usage of compiler with full profiling"/>
  31. <echo message=" ajdt.compile.gc : source compile simulating ajdt usage of compiler with basic timing and gc"/>
  32. <echo message=" clean : remove all output etc. and prepare for fresh run"/>
  33. <echo message="results are placed in ${results.dir} for analysis with HAT, PerfAnal etc."/>
  34. <echo message="customise behaviour using local project.properties (see build.properties"/>
  35. <echo message="for available customisations)"/>
  36. </target>
  37. <!-- handy suites -->
  38. <target name="gc.suite" depends="source.compile.gc,binary.weave.gc,loadtime.weave.gc,ajdt.compile.gc"/>
  39. <target name="full.profile.suite" depends="source.compile,binary.weave,loadtime.weave,ajdt.compile"/>
  40. <!--
  41. how to obtain the aspectj compiler - if the use.aspectjtools.jar property
  42. is set to true, will use the version of aspectjtools.jar in
  43. aspectj.lib.dir. If use.aspectjtools.jar property is false, will use
  44. the bin directories from the projects in your aspectj.workspace.root.
  45. -->
  46. <condition property="ajtools.jar">
  47. <istrue value="${use.aspectjtools.jar}"/>
  48. </condition>
  49. <condition property="iajc.local">
  50. <istrue value="${use.local.iajc.task.class}"/>
  51. </condition>
  52. <path id="aspectj.compiler.path">
  53. <dirset dir=".">
  54. <include name="classes" if="iajc.local"/>
  55. </dirset>
  56. <fileset dir="${aspectj.lib.dir}">
  57. <include name="aspectjtools.jar" if="ajtools.jar"/>
  58. </fileset>
  59. <dirset dir="${aspectj.workspace.root}">
  60. <include name="*/bin" unless="ajtools.jar"/>
  61. </dirset>
  62. <fileset dir="${aspectj.workspace.root}">
  63. <include name="lib/jdtcore-aj/jdtcore-for-aspectj.jar" unless="ajtools.jar"/>
  64. <include name="lib/bcel/bcel.jar" unless="ajtools.jar"/>
  65. </fileset>
  66. </path>
  67. <path id="ajde.launch.path">
  68. <dirset dir="${aspectj.workspace.root}">
  69. <include name="test*/bin"/>
  70. </dirset>
  71. </path>
  72. <!-- define the iajc task -->
  73. <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
  74. <classpath>
  75. <path refid="aspectj.compiler.path"/>
  76. </classpath>
  77. </taskdef>
  78. <!-- some simple checking to give status messages about the config we will run with -->
  79. <target name="config-check" depends="check.ajtools.jar,check.workspace,check.iajc.local,check.iajc.ajtools"/>
  80. <target name="check.ajtools.jar" if="ajtools.jar">
  81. <echo message="using aspectjtools.jar from ${aspectj.lib.dir}"/>
  82. </target>
  83. <target name="check.workspace" unless="ajtools.jar">
  84. <echo message="using AspectJ from workspace at ${aspectj.workspace.root}"/>
  85. </target>
  86. <target name="check.iajc.local" if="iajc.local">
  87. <echo message="using patched version of iajc supporting jvmargs"/>
  88. </target>
  89. <target name="check.iajc.ajtools" unless="iajc.local">
  90. <echo message="using version of iajc from aspectjtools.jar"/>
  91. </target>
  92. <!-- init and clean... -->
  93. <target name="init">
  94. <mkdir dir="${results.dir}"/>
  95. <mkdir dir="${results.dir}/${target.application.name}"/>
  96. <mkdir dir="${results.dir}/ltw-app"/>
  97. <mkdir dir="${results.dir}/ltw-app/META-INF"/>
  98. </target>
  99. <target name="clean" depends="init">
  100. <delete dir="${results.dir}"/>
  101. </target>
  102. <!-- classpath to use for all targets -->
  103. <path id="iajc.class.path">
  104. <path refid="build.class.path"/>
  105. <pathelement location="${aspectj.lib.dir}/aspectjrt.jar"/>
  106. <path refid="aspectj.compiler.path"/>
  107. </path>
  108. <!-- source compilation (ajc style) with various profiling -->
  109. <target name="source.compile" depends="init,config-check">
  110. <iajc destdir="${results.dir}/${target.application.name}/classes"
  111. fork="true" maxmem="${ajc.maxmem}"
  112. debug="on"
  113. source="${source.level}" target="${target.level}"
  114. sourcerootsref="source.roots"
  115. time="true"
  116. forkclasspathref="iajc.class.path">
  117. <jvmarg value="${hprof.args}"/>
  118. <jvmarg value="${gc.args}"/>
  119. </iajc>
  120. <tstamp>
  121. <format property="ajc.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  122. </tstamp>
  123. <property name="ajc.hprof.out" value="${results.dir}/${target.application.name}/ajc.java.hprof.${ajc.runtime}.txt"/>
  124. <property name="ajc.gc.out" value="${results.dir}/${target.application.name}/ajc.gc.${ajc.runtime}.txt"/>
  125. <move file="java.hprof.txt" tofile="${ajc.hprof.out}"/>
  126. <move file="gc.txt" tofile="${ajc.gc.out}"/>
  127. <echo message="hprof data written to ${ajc.hprof.out}"/>
  128. <echo message="gc data written to ${ajc.gc.out}"/>
  129. <echo message="analyse with e.g. HATS and JTune"/>
  130. </target>
  131. <target name="source.compile.gc" depends="init,config-check">
  132. <tstamp>
  133. <format property="ajc.starttime" pattern="HH:mm:ss"/>
  134. </tstamp>
  135. <echo message="ajc compile started at: ${ajc.starttime}"/>
  136. <iajc destdir="${results.dir}/${target.application.name}/classes"
  137. fork="true" maxmem="${ajc.maxmem}"
  138. debug="on"
  139. source="${source.level}" target="${target.level}"
  140. sourcerootsref="source.roots"
  141. forkclasspathref="iajc.class.path"
  142. time="true">
  143. <jvmarg value="${gc.args}"/>
  144. </iajc>
  145. <tstamp>
  146. <format property="ajc.endtime" pattern="HH:mm:ss"/>
  147. </tstamp>
  148. <echo message="ajc compile ended at: ${ajc.endtime} (started at ${ajc.starttime})"/>
  149. <tstamp>
  150. <format property="ajc.gc.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  151. </tstamp>
  152. <property name="ajc.gc.only.out" value="${results.dir}/${target.application.name}/ajc.gc.${ajc.gc.runtime}.txt"/>
  153. <move file="gc.txt" tofile="${ajc.gc.only.out}"/>
  154. <echo message="gc data written to ${ajc.gc.only.out}"/>
  155. <echo message="analyze with JTune"/>
  156. </target>
  157. <!-- binary weaving with various profiling options -->
  158. <!-- build an aspect library to use for binary weaving, so that we
  159. profile weaving only... -->
  160. <target name="aspectlib" depends="init">
  161. <iajc outjar="${results.dir}/aspectlib.jar"
  162. debug="on"
  163. source="${source.level}"
  164. target="${target.level}"
  165. sourceroots="${test.aspects.src.dir}"
  166. sourceRootCopyFilter="**/*.java,**/*.aj,**/CVS/*"
  167. classpathref="iajc.class.path">
  168. </iajc>
  169. </target>
  170. <target name="binary.weave" depends="init,aspectlib">
  171. <iajc outjar="${results.dir}/woven.jar"
  172. debug="on"
  173. source="${source.level}"
  174. target="${target.level}"
  175. fork="true"
  176. forkclasspathref="iajc.class.path"
  177. maxmem="${ajc.maxmem}">
  178. <inpath>
  179. <pathelement location="${weave.injar}"/>
  180. </inpath>
  181. <aspectpath>
  182. <pathelement location="${results.dir}/aspectlib.jar"/>
  183. </aspectpath>
  184. <jvmarg value="${hprof.args}"/>
  185. <jvmarg value="${gc.args}"/>
  186. </iajc>
  187. <tstamp>
  188. <format property="bw.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  189. </tstamp>
  190. <property name="bw.hprof.out" value="${results.dir}/${target.application.name}/weave.java.hprof.${bw.runtime}.txt"/>
  191. <property name="bw.gc.out" value="${results.dir}/${target.application.name}/weave.gc.${bw.runtime}.txt"/>
  192. <move file="java.hprof.txt" tofile="${bw.hprof.out}"/>
  193. <move file="gc.txt" tofile="${bw.gc.out}"/>
  194. <echo message="hprof data written to ${bw.hprof.out}"/>
  195. <echo message="gc data written to ${bw.gc.out}"/>
  196. <echo message="analyse with e.g. HATS and JTune"/>
  197. </target>
  198. <target name="binary.weave.gc" depends="init,aspectlib">
  199. <tstamp>
  200. <format property="bw.starttime" pattern="HH:mm:ss"/>
  201. </tstamp>
  202. <echo message="weave started at: ${bw.starttime}"/>
  203. <iajc outjar="${results.dir}/woven.jar"
  204. debug="on"
  205. source="${source.level}"
  206. target="${target.level}"
  207. fork="true"
  208. forkclasspathref="iajc.class.path"
  209. maxmem="${ajc.maxmem}">
  210. <inpath>
  211. <pathelement location="${weave.injar}"/>
  212. </inpath>
  213. <aspectpath>
  214. <pathelement location="${results.dir}/aspectlib.jar"/>
  215. </aspectpath>
  216. <jvmarg value="${gc.args}"/>
  217. </iajc>
  218. <tstamp>
  219. <format property="bw.endtime" pattern="HH:mm:ss"/>
  220. </tstamp>
  221. <echo message="weave ended at: ${bw.endtime} (started at ${bw.starttime})"/>
  222. <tstamp>
  223. <format property="bw.gc.only.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  224. </tstamp>
  225. <property name="bw.gc.only.out" value="${results.dir}/${target.application.name}/weave.gc.${bw.gc.only.runtime}.txt"/>
  226. <move file="gc.txt" tofile="${bw.gc.only.out}"/>
  227. <echo message="gc data written to ${bw.gc.only.out}"/>
  228. <echo message="analyze with JTune"/>
  229. </target>
  230. <!-- loadtime weaving with various profiling options -->
  231. <target name="ltw-app" depends="init"
  232. description="builds an application that we can run with ltw. The app does
  233. Class.forName(..) on every type within the jar file passed to
  234. it as an argument, thus forcing all those types (and types they
  235. reference) to be woven)">
  236. <javac srcdir="ltw-app/src" destdir="${results.dir}/ltw-app">
  237. </javac>
  238. <copy file="${ltw.aop.xml}" todir="${results.dir}/ltw-app/META-INF"/>
  239. </target>
  240. <target name="check-using-jars" unless="ajtools.jar">
  241. <echo message="WARNING: cannot run load-time weaving from workspace dirs"/>
  242. <echo message="use.aspectjtools.jar setting will be ignored and the jar"/>
  243. <echo message="${aspectj.lib.dir}/aspectjweaver.jar will be used for LTW instead"/>
  244. </target>
  245. <target name="loadtime.weave" depends="check-using-jars,aspectlib,ltw-app">
  246. <java classname="org.aspectj.profiling.LTWApp"
  247. fork="true"
  248. maxmemory="${ajc.maxmem}">
  249. <arg value="${weave.injar}"/>
  250. <jvmarg value="${gc.args}"/>
  251. <jvmarg value="${hprof.args}"/>
  252. <jvmarg value="-javaagent:${aspectj.lib.dir}/aspectjweaver.jar"/>
  253. <!-- <jvmarg value="${aj.addOpensKey}"/>-->
  254. <!-- <jvmarg value="${aj.addOpensValue}"/>-->
  255. <classpath>
  256. <pathelement location="${results.dir}/ltw-app"/>
  257. <pathelement location="${results.dir}/aspectlib.jar"/>
  258. <pathelement location="${weave.injar}"/>
  259. <path refid="iajc.class.path"/>
  260. </classpath>
  261. </java>
  262. <tstamp>
  263. <format property="ltw.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  264. </tstamp>
  265. <property name="ltw.hprof.out" value="${results.dir}/${target.application.name}/ltw.java.hprof.${ltw.runtime}.txt"/>
  266. <property name="ltw.gc.out" value="${results.dir}/${target.application.name}/ltw.gc.${ltw.runtime}.txt"/>
  267. <move file="java.hprof.txt" tofile="${ltw.hprof.out}"/>
  268. <move file="gc.txt" tofile="${ltw.gc.out}"/>
  269. <echo message="hprof data written to ${ltw.hprof.out}"/>
  270. <echo message="gc data written to ${ltw.gc.out}"/>
  271. <echo message="analyse with e.g. HATS and JTune"/>
  272. </target>
  273. <target name="loadtime.weave.gc" depends="check-using-jars,aspectlib,ltw-app">
  274. <tstamp>
  275. <format property="ltw.starttime" pattern="HH:mm:ss"/>
  276. </tstamp>
  277. <echo message="ltw started at: ${ltw.starttime}"/>
  278. <java classname="org.aspectj.profiling.LTWApp"
  279. fork="true"
  280. maxmemory="${ajc.maxmem}">
  281. <arg value="${weave.injar}"/>
  282. <jvmarg value="${gc.args}"/>
  283. <jvmarg value="-javaagent:${aspectj.lib.dir}/aspectjweaver.jar"/>
  284. <!-- <jvmarg value="${aj.addOpensKey}"/>-->
  285. <!-- <jvmarg value="${aj.addOpensValue}"/>-->
  286. <classpath>
  287. <pathelement location="${results.dir}/ltw-app"/>
  288. <pathelement location="${results.dir}/aspectlib.jar"/>
  289. <pathelement location="${weave.injar}"/>
  290. <path refid="iajc.class.path"/>
  291. </classpath>
  292. </java>
  293. <tstamp>
  294. <format property="ltw.endtime" pattern="HH:mm:ss"/>
  295. </tstamp>
  296. <echo message="ltw ended at: ${ltw.endtime} (started at ${ltw.starttime})"/>
  297. <tstamp>
  298. <format property="ltw.gc.only.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  299. </tstamp>
  300. <property name="ltw.gc.only.out" value="${results.dir}/${target.application.name}/ltw.gc.${ltw.gc.only.runtime}.txt"/>
  301. <move file="gc.txt" tofile="${ltw.gc.only.out}"/>
  302. <echo message="gc data written to ${ltw.gc.only.out}"/>
  303. <echo message="analyze with JTune"/>
  304. </target>
  305. <!-- "AJDT-like" compiles with various profiling options -->
  306. <target name="prepare-project" depends="init">
  307. <delete dir="${results.dir}/ajdt-workspace-root"/>
  308. <mkdir dir="${results.dir}/ajdt-workspace-root"/>
  309. <mkdir dir="${results.dir}/ajdt-workspace-root/${target.application.name}"/>
  310. <mkdir dir="${results.dir}/ajdt-workspace-root/${target.application.name}/base"/>
  311. <antcall target="copy.source.files">
  312. <param name="todir" value="${results.dir}/ajdt-workspace-root/${target.application.name}/base"/>
  313. </antcall>
  314. </target>
  315. <target name="ajdt.compile" depends="prepare-project">
  316. <java classname="org.aspectj.systemtest.incremental.tools.AjdeInteractionTestbedLauncher"
  317. fork="true"
  318. maxmemory="${ajc.maxmem}">
  319. <arg value="${results.dir}/ajdt-workspace-root"/>
  320. <arg value="${target.application.name}"/>
  321. <jvmarg value="${gc.args}"/>
  322. <jvmarg value="${hprof.args}"/>
  323. <classpath>
  324. <path refid="iajc.class.path"/>
  325. <path refid="ajde.launch.path"/>
  326. <pathelement location="${aspectj.lib.dir}/aspectjrt.jar"/>
  327. </classpath>
  328. </java>
  329. <tstamp>
  330. <format property="ajdt.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  331. </tstamp>
  332. <property name="ajdt.hprof.out" value="${results.dir}/${target.application.name}/ajdt.java.hprof.${ajdt.runtime}.txt"/>
  333. <property name="ajdt.gc.out" value="${results.dir}/${target.application.name}/ajdt.gc.${ajdt.runtime}.txt"/>
  334. <move file="java.hprof.txt" tofile="${ajdt.hprof.out}"/>
  335. <move file="gc.txt" tofile="${ajdt.gc.out}"/>
  336. <echo message="hprof data written to ${ajdt.hprof.out}"/>
  337. <echo message="gc data written to ${ajdt.gc.out}"/>
  338. <echo message="analyse with e.g. HATS and JTune"/>
  339. </target>
  340. <target name="ajdt.compile.gc" depends="prepare-project">
  341. <tstamp>
  342. <format property="ajdt.starttime" pattern="HH:mm:ss"/>
  343. </tstamp>
  344. <echo message="AJDT started at: ${ajdt.starttime}"/>
  345. <java classname="org.aspectj.systemtest.incremental.tools.AjdeInteractionTestbedLauncher"
  346. fork="true"
  347. maxmemory="${ajc.maxmem}">
  348. <arg value="${results.dir}/ajdt-workspace-root"/>
  349. <arg value="${target.application.name}"/>
  350. <jvmarg value="${gc.args}"/>
  351. <classpath>
  352. <path refid="iajc.class.path"/>
  353. <path refid="ajde.launch.path"/>
  354. <pathelement location="${aspectj.lib.dir}/aspectjrt.jar"/>
  355. </classpath>
  356. </java>
  357. <tstamp>
  358. <format property="ajdt.endtime" pattern="HH:mm:ss"/>
  359. </tstamp>
  360. <echo message="AJDT ended at: ${ajdt.endtime} (started at ${ajdt.starttime})"/>
  361. <tstamp>
  362. <format property="ajdt.gc.only.runtime" pattern="yyyy-MM-dd'T'HHmmss"/>
  363. </tstamp>
  364. <property name="ajdt.gc.only.out" value="${results.dir}/${target.application.name}/ajdt.gc.${ajdt.gc.only.runtime}.txt"/>
  365. <move file="gc.txt" tofile="${ajdt.gc.only.out}"/>
  366. <echo message="gc data written to ${ajdt.gc.only.out}"/>
  367. <echo message="analyze with JTune"/>
  368. </target>
  369. </project>