1 <?xml version="1.0" encoding="UTF-8"?>
   2 
   3 <!--
   4     Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
   5     DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6 
   7     This code is free software; you can redistribute it and/or modify it
   8     under the terms of the GNU General Public License version 2 only, as
   9     published by the Free Software Foundation.
  10 
  11     This code is distributed in the hope that it will be useful, but WITHOUT
  12     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14     version 2 for more details (a copy is included in the LICENSE file that
  15     accompanied this code).
  16 
  17     You should have received a copy of the GNU General Public License version
  18     2 along with this work; if not, write to the Free Software Foundation,
  19     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 
  21     Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22     or visit www.oracle.com if you need additional information or have any
  23     questions.
  24 -->
  25 
  26 
  27 <project
  28     name="nashorn-benchmarks"
  29     default="all"
  30     basedir=".."
  31     xmlns:if="ant:if">
  32 
  33   <!--
  34        Below are the octane benchmarks that should be run.
  35        The ones that are excluded, as Nashorn currently has
  36        some issues with them (functionality or performance)
  37        are commented out
  38   -->
  39 
  40   <!-- box2d -->
  41   <target name="octane-box2d" depends="octane-box2d-nashorn"/>
  42   <target name="octane-box2d-nashorn" depends="jar">
  43     <run-one cond="octane.benchmark.box2d" runtime="nashorn"/>
  44   </target>
  45   <target name="octane-box2d-v8" depends="jar">
  46     <run-one cond="octane.benchmark.box2d" runtime="v8"/>
  47   </target>
  48   <target name="octane-box2d-rhino" depends="jar">
  49     <run-one cond="octane.benchmark.box2d" runtime="rhino"/>
  50   </target>
  51 
  52   <!-- code-load -->
  53   <target name="octane-code-load" depends="octane-code-load-nashorn"/>
  54   <target name="octane-code-load-nashorn" depends="jar">
  55     <run-one cond="octane.benchmark.code-load" runtime="nashorn"/>
  56   </target>
  57   <target name="octane-code-load-v8" depends="jar">
  58     <run-one cond="octane.benchmark.code-load" runtime="v8"/>
  59   </target>
  60   <target name="octane-code-load-rhino" depends="jar">
  61     <run-one cond="octane.benchmark.code-load" runtime="rhino"/>
  62   </target>
  63 
  64   <!-- crypto -->
  65   <target name="octane-crypto" depends="octane-crypto-nashorn"/>
  66   <target name="octane-crypto-nashorn" depends="jar">
  67     <run-one cond="octane.benchmark.crypto" runtime="nashorn"/>
  68   </target>
  69   <target name="octane-crypto-v8" depends="jar">
  70     <run-one cond="octane.benchmark.crypto" runtime="v8"/>
  71   </target>
  72   <target name="octane-crypto-rhino" depends="jar">
  73     <run-one cond="octane.benchmark.crypto" runtime="rhino"/>
  74   </target>
  75 
  76   <!-- deltablue -->
  77   <target name="octane-deltablue" depends="octane-deltablue-nashorn"/>
  78   <target name="octane-deltablue-nashorn" depends="jar">
  79     <run-one cond="octane.benchmark.deltablue" runtime="nashorn"/>
  80   </target>
  81   <target name="octane-deltablue-v8" depends="jar">
  82     <run-one cond="octane.benchmark.deltablue" runtime="v8"/>
  83   </target>
  84   <target name="octane-deltablue-rhino" depends="jar">
  85     <run-one cond="octane.benchmark.deltablue" runtime="rhino"/>
  86   </target>
  87 
  88   <!-- earley-boyer -->
  89   <target name="octane-earley-boyer" depends="octane-earley-boyer-nashorn"/>
  90   <target name="octane-earley-boyer-nashorn" depends="jar">
  91     <run-one cond="octane.benchmark.earley-boyer" runtime="nashorn"/>
  92   </target>
  93   <target name="octane-earley-boyer-v8" depends="jar">
  94     <run-one cond="octane.benchmark.earley-boyer" runtime="v8"/>
  95   </target>
  96   <target name="octane-earley-boyer-rhino" depends="jar">
  97     <run-one cond="octane.benchmark.earley-boyer" runtime="rhino"/>
  98   </target>
  99   
 100   <!-- gbemu -->
 101   <target name="octane-gbemu" depends="octane-gbemu-nashorn"/>
 102   <target name="octane-gbemu-nashorn" depends="jar">
 103     <run-one cond="octane.benchmark.gbemu" runtime="nashorn"/>
 104   </target>
 105   <target name="octane-gbemu-v8" depends="jar">
 106     <run-one cond="octane.benchmark.gbemu" runtime="v8"/>
 107   </target>
 108   <target name="octane-gbemu-rhino" depends="jar">
 109     <run-one cond="octane.benchmark.gbemu" runtime="rhino"/>
 110   </target>
 111 
 112   <!-- mandreel -->
 113   <target name="octane-mandreel" depends="octane-mandreel-nashorn"/>
 114   <target name="octane-mandreel-nashorn" depends="jar">
 115     <run-one cond="octane.benchmark.mandreel" runtime="nashorn"/>
 116   </target>
 117   <target name="octane-mandreel-v8" depends="jar">
 118     <run-one cond="octane.benchmark.mandreel" runtime="v8"/>
 119   </target>
 120   <target name="octane-mandreel-rhino" depends="jar">
 121     <run-one cond="octane.benchmark.mandreel" runtime="rhino"/>
 122   </target>
 123 
 124   <!-- navier-stokes -->
 125   <target name="octane-navier-stokes" depends="octane-navier-stokes-nashorn"/>
 126   <target name="octane-navier-stokes-nashorn" depends="jar">
 127     <run-one cond="octane.benchmark.navier-stokes" runtime="nashorn"/>
 128   </target>
 129   <target name="octane-navier-stokes-v8" depends="jar">
 130     <run-one cond="octane.benchmark.navier-stokes" runtime="v8"/>
 131   </target>
 132   <target name="octane-navier-stokes-rhino" depends="jar">
 133     <run-one cond="octane.benchmark.navier-stokes" runtime="rhino"/>
 134   </target>
 135 
 136   <!-- pdfjs -->
 137   <target name="octane-pdfjs" depends="octane-pdfjs-nashorn"/>
 138   <target name="octane-pdfjs-nashorn" depends="jar">
 139     <run-one cond="octane.benchmark.pdfjs" runtime="nashorn"/>
 140   </target>
 141   <target name="octane-pdfjs-v8" depends="jar">
 142     <run-one cond="octane.benchmark.pdfjs" runtime="v8"/>
 143   </target>
 144   <target name="octane-pdfjs-rhino" depends="jar">
 145     <run-one cond="octane.benchmark.pdfjs" runtime="rhino"/>
 146   </target>
 147 
 148   <!-- raytrace -->
 149   <target name="octane-raytrace" depends="octane-raytrace-nashorn"/>
 150   <target name="octane-raytrace-nashorn" depends="jar">
 151     <run-one cond="octane.benchmark.raytrace" runtime="nashorn"/>
 152   </target>
 153   <target name="octane-raytrace-v8" depends="jar">
 154     <run-one cond="octane.benchmark.raytrace" runtime="v8"/>
 155   </target>
 156   <target name="octane-raytrace-rhino" depends="jar">
 157     <run-one cond="octane.benchmark.raytrace" runtime="rhino"/>
 158   </target>
 159 
 160   <!-- regexp -->
 161   <target name="octane-regexp" depends="octane-regexp-nashorn"/>
 162   <target name="octane-regexp-nashorn" depends="jar">
 163     <run-one cond="octane.benchmark.regexp" runtime="nashorn"/>
 164   </target>
 165   <target name="octane-regexp-v8" depends="jar">
 166     <run-one cond="octane.benchmark.regexp" runtime="v8"/>
 167   </target>
 168   <target name="octane-regexp-rhino" depends="jar">
 169     <run-one cond="octane.benchmark.regexp" runtime="rhino"/>
 170   </target>
 171 
 172   <!-- richards -->
 173   <target name="octane-richards" depends="octane-richards-nashorn"/>
 174   <target name="octane-richards-nashorn" depends="jar">
 175     <run-one cond="octane.benchmark.richards" runtime="nashorn"/>
 176   </target>
 177   <target name="octane-richards-v8" depends="jar">
 178     <run-one cond="octane.benchmark.richards" runtime="v8"/>
 179   </target>
 180   <target name="octane-richards-rhino" depends="jar">
 181     <run-one cond="octane.benchmark.richards" runtime="rhino"/>
 182   </target>
 183 
 184   <!-- splay -->
 185   <target name="octane-splay" depends="octane-splay-nashorn"/>
 186   <target name="octane-splay-nashorn" depends="jar">
 187     <run-one cond="octane.benchmark.splay" runtime="nashorn"/>
 188   </target>
 189   <target name="octane-splay-v8" depends="jar">
 190     <run-one cond="octane.benchmark.splay" runtime="v8"/>
 191   </target>
 192   <target name="octane-splay-rhino" depends="jar">
 193     <run-one cond="octane.benchmark.splay" runtime="rhino"/>
 194   </target>
 195 
 196   <!-- typescript -->
 197   <target name="octane-typescript" depends="octane-typescript-nashorn"/>
 198   <target name="octane-typescript-nashorn" depends="jar">
 199     <run-one cond="octane.benchmark.typescript" runtime="nashorn"/>
 200   </target>
 201   <target name="octane-typescript-v8" depends="jar">
 202     <run-one cond="octane.benchmark.typescript" runtime="v8"/>
 203   </target>
 204   <target name="octane-typescript-rhino" depends="jar">
 205     <run-one cond="octane.benchmark.typescript" runtime="rhino"/>
 206   </target>
 207 
 208   <!-- zlib -->
 209   <target name="octane-zlib" depends="octane-zlib-nashorn"/>
 210   <target name="octane-zlib-nashorn" depends="jar">
 211     <run-one cond="octane.benchmark.zlib" runtime="nashorn"/>
 212   </target>
 213   <target name="octane-zlib-v8" depends="jar">
 214     <run-one cond="octane.benchmark.zlib" runtime="v8"/>
 215   </target>
 216   <target name="octane-zlib-rhino" depends="jar">
 217     <run-one cond="octane.benchmark.zlib" runtime="rhino"/>
 218   </target>
 219 
 220   <!--
 221       Benchmark runners for one or more benchmarks, single
 222       or multiple process
 223   -->
 224 
 225   <target name="octane-process-separate" if="${octane-test-sys-prop.separate.process}">
 226     <echo message="Running each benchmark in separate processes, starting new JVMs for each."/>
 227     <script language="javascript"><![CDATA[
 228       var props = [];
 229 
 230       for (var prop in project.getProperties()) {
 231         if (prop.startsWith("octane.benchmark.")) {
 232           props.push(prop);
 233         }
 234       }
 235 
 236       //sort benchmark props in alphabetical order by name
 237       props.sort(function(a, b) {
 238         if (a < b) {
 239           return -1;
 240         } else if (a > b) {
 241           return 1;
 242         } else {
 243            return 0;
 244         }
 245       });
 246       
 247       var runtime = project.getProperty("runtime");
 248 
 249       for (var i in props) {
 250         var task = project.createTask("run-one");
 251         // workaround for https://issues.apache.org/bugzilla/show_bug.cgi?id=53831, still not fixed
 252         if (task.getOwningTarget() == null) {
 253           task.setOwningTarget(self.getOwningTarget());
 254         }
 255         var prop = props[i];
 256         task.setDynamicAttribute("cond", prop);
 257         task.setDynamicAttribute("runtime", runtime);
 258         task.perform();
 259       }
 260     ]]></script>
 261   </target>
 262 
 263   <target name="octane-process-single" unless="${octane-test-sys-prop.separate.process}">
 264     <echo message="Running all benchmarks in the same process."/>
 265     <pathconvert property="octane.benchmarks" pathsep=" ">
 266       <propertyset>
 267     <propertyref prefix="octane.benchmark."/>
 268       </propertyset>
 269     </pathconvert>
 270     <antcall target="run-octane${runtime}">
 271       <param name="octane-tests" value="${octane.benchmarks}"/>
 272     </antcall>
 273   </target>
 274 
 275   <!--
 276        run 'octane' in single or separate processes based on config
 277        This uses nashorn as the default runtime
 278   -->
 279   <target name="octane-nashorn" depends="jar">
 280     <property name="runtime" value="nashorn"/>
 281     <antcall target="octane-process-separate"/>
 282     <antcall target="octane-process-single"/>
 283   </target>
 284 
 285   <!-- alias for 'octane' -->
 286   <target name="octane" depends="octane-nashorn"/>
 287 
 288   <!-- run octane benchmarks using octane as runtime -->
 289   <target name="octane-v8" depends="jar">
 290     <property name="runtime" value="v8"/>
 291     <antcall target="octane-process-separate"/>
 292     <antcall target="octane-process-single"/>
 293   </target>
 294 
 295   <!-- run octane benchmarks using Rhino as runtime -->
 296   <target name="octane-rhino" depends="jar">
 297     <property name="runtime" value="rhino"/>
 298     <antcall target="octane-process-separate"/>
 299     <antcall target="octane-process-single"/>
 300   </target>
 301 
 302   <macrodef name="run-one">
 303     <attribute name="cond"/>
 304     <attribute name="runtime" default=""/>
 305     <sequential>
 306         <antcall target="run-octane-@{runtime}" if:set="@{cond}">
 307           <param name="octane-tests" value="${@{cond}}"/>
 308         </antcall>
 309     </sequential>
 310   </macrodef>
 311 
 312   <target name="run-octane-nashorn">
 313     <java classname="${nashorn.shell.tool}"
 314           classpath="${run.test.classpath}"
 315           fork="true"
 316           dir=".">
 317       <jvmarg line="${boot.class.path}"/>
 318       <jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
 319       <!-- pass on all properties prefixed with 'nashorn' to the runtime -->
 320       <syspropertyset>
 321         <propertyref prefix="nashorn."/>
 322       </syspropertyset>
 323       <arg value="${octane-test-sys-prop.test.js.framework}"/>
 324       <arg value="-scripting"/>
 325       <arg value="--"/>
 326       <arg value="${octane-tests}"/>
 327       <arg value="--runtime"/>
 328       <arg value="nashorn"/>
 329       <arg value="--verbose"/>
 330       <arg value="--iterations ${octane.iterations}"/>
 331     </java>
 332   </target>
 333 
 334   <target name="run-octane-v8">
 335     <exec executable="${v8.shell}">
 336       <arg value="${octane-test-sys-prop.test.js.framework}"/>
 337       <arg value="--"/>
 338       <arg value="${octane-tests}"/>
 339       <arg value="--runtime"/>
 340       <arg value="v8"/>
 341       <arg value="--verbose"/>
 342       <arg value="--iterations ${octane.iterations}"/>
 343     </exec>
 344   </target>
 345 
 346   <target name="run-octane-rhino">
 347     <java jar="${rhino.jar}"
 348           classpath="${run.test.classpath}"
 349           fork="true"
 350           dir=".">
 351       <jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
 352       <arg value="-opt"/>
 353       <arg value="9"/>
 354       <arg value="${octane-test-sys-prop.test.js.framework}"/>
 355       <arg value="${octane-tests}"/>
 356       <arg value="--runtime"/>
 357       <arg value="rhino"/>
 358       <arg value="--verbose"/>
 359       <arg value="--iterations ${octane.iterations}"/>
 360     </java>
 361   </target>
 362 
 363   <!-- run octane with all known runtimes for comparison -->
 364   <target name="octane-all" depends="octane, octane-v8, octane-rhino">
 365     <exec executable="${v8.shell}">
 366       <arg value="${octane-test-sys-prop.test.js.framework}"/>
 367       <arg value="${octane-tests}/"/>
 368     </exec>
 369   </target>
 370 
 371   <target name="sunspider-init" depends="jar">
 372     <fileset id="sunspider-set"
 373          dir="${sunspider-test-sys-prop.test.js.roots}"
 374          excludes="${sunspider-test-sys-prop.test.js.exclude.list}">
 375       <include name="**/*.js"/>
 376     </fileset>
 377     <pathconvert pathsep=" " property="sunspider-tests" refid="sunspider-set"/>
 378   </target>
 379 
 380   <!--- SUNSPIDER JOB BELOW -->
 381 
 382   <!-- run sunspider with Nashorn -->
 383   <target name="sunspider" depends="sunspider-nashorn"/>
 384 
 385   <target name="sunspider-nashorn" depends="sunspider-init">
 386     <java classname="${nashorn.shell.tool}"
 387           classpath="${run.test.classpath}"
 388           fork="true"
 389           dir=".">
 390       <jvmarg line="${boot.class.path}"/>
 391       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
 392       <arg value="-timezone=PST"/>
 393       <arg value="--class-cache-size=50"/>
 394       <arg value="${sunspider-test-sys-prop.test.js.framework}"/>
 395       <arg value="--"/>
 396       <arg value="${sunspider-tests}/"/>
 397       <arg value="--verbose"/>
 398       <arg value="--times"/>
 399       <arg value="${sunspider.iterations}"/>
 400     </java>
 401   </target>
 402 
 403   <!-- run sunspider with v8 -->
 404   <target name="sunspider-v8" depends="sunspider-init">
 405     <exec executable="${v8.shell}">
 406       <arg value="${sunspider-test-sys-prop.test.js.framework}"/>
 407       <arg value="--"/>
 408       <arg value="${sunspider-tests}/"/>
 409       <arg value="--verbose"/>
 410       <arg value="--times"/>
 411       <arg value="${sunspider.iterations}"/>
 412     </exec>
 413   </target>
 414 
 415   <!-- run sunspider with Rhino -->
 416   <target name="sunspider-rhino" depends="sunspider-init">
 417     <java jar="${rhino.jar}"
 418           classpath="${run.test.classpath}"
 419           fork="true"
 420           dir=".">
 421       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
 422       <arg value="-opt"/>
 423       <arg value="9"/>
 424       <arg value="${sunspider-test-sys-prop.test.js.framework}"/>
 425       <arg value="${sunspider-tests}/"/>
 426       <arg value="--verbose"/>
 427       <arg value="--times"/>
 428       <arg value="${sunspider.iterations}"/>
 429     </java>
 430   </target>
 431 
 432 </project>