summaryrefslogtreecommitdiff
path: root/test/benchmark/predef.xml
blob: f3ae43a7f07c12d6506469f1fcced904cae2a6df (plain) (blame)
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
<project name="predef">
 
  <!-- Redefine accordingly to where you checked out your scala files -->
  <!-- scala.home should point to the directory that contains the     -->
  <!-- "benchmark" directory                                          -->
  <property name="scala.home" value="${user.home}/scala"/>

  <!-- Define some basic paths  -->
  <property name="benchmark.home" value="${scala.home}/test/benchmark"/>
  <property name="benchmark.sources.dir"
            value="${benchmark.home}/sources"/>	 
  <property name="benchmark.classes.dir"
            value="${benchmark.home}/classes"/>
  <property name="log.file"
            value="${benchmark.home}/times/times.log"/>

  <!--  Define a <run-benchmark> element that can be used to run   -->
  <!--    benchmarks                                               -->
  <!--  It accepts these attributes:                               -->
  <!--    count - how many times to run each benchmark (default:3) -->
  <!--    classname - the name of the class to be ran  (default:   -->
  <!--                the name of the ant project                  -->
  <!--    logfile - the location of the file where running times   -->
  <!--              are logged (default: ${log.file} property)     -->
  <!--    location - the location of the classfiles: it will end   -->
  <!--               up as head of the current classpath (default: -->
  <!--               benchmark classes dir/project name            -->
  <macrodef name="run-benchmark">
    <attribute name="count" default="3"/>
    <attribute name="classname" default="benchmarks.${ant.project.name}"/>
    <attribute name="logfile" default="${log.file}"/>
    <attribute name="location" default="${benchmark.classes.dir}/${ant.project.name}"/>

    <sequential>
      <echo>** Running benchmark @{classname} in @{location}..</echo>
      <exec executable="scala" failonerror="true">
        <arg line="-cp @{location}:${java.class.path}"/>
	<arg line="@{classname} @{count} @{logfile}"/>
      </exec>
      <echo>Done</echo>
    </sequential>
  </macrodef>

  <!--  Define a <compile-benchmark> element that can be used to   -->
  <!--    compile benchmarks                                       -->
  <!--  It accepts these attributes:                               -->
  <!--    compiler - the name of the scalac compiler to use. It is -->
  <!--            useful in case you have multiple compilers       -->
  <!--            installed (default: scalac)                      -->
  <!--    additionalArgs - additional arguments to pass to scalac  -->
  <!--            (default: none)                                  -->
  <!--    destination - the location where class files should be   -->
  <!--            created (default: benchmark classes dir/project  -->
  <!--            name)                                            -->
  <!--    files - the source files to be compiled                  -->
  <macrodef name="compile-benchmark">
    <attribute name="compiler" default="myscalac"/>
    <attribute name="additionalArgs" default=""/>
    <attribute name="destination" default="${benchmark.classes.dir}/${ant.project.name}"/>
    <attribute name="files"/>

    <sequential>
      <echo>
** Building project ${ant.project.name} to @{destination}</echo>

      <exec executable="@{compiler}" failonerror="true">
        <arg line="-d @{destination}"/>
	<arg line="@{additionalArgs}"/>
        <arg line="@{files}"/>
      </exec>
    </sequential>
  </macrodef>

</project>