Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何知道目标在ant中执行所花费的时间_Java_Ant - Fatal编程技术网

Java 如何知道目标在ant中执行所花费的时间

Java 如何知道目标在ant中执行所花费的时间,java,ant,Java,Ant,是否有一种方法可以知道目标在ant脚本中执行并将该时间存储在属性中所花费的时间。我已经通过了tstamp和秒表,但我没有得到正确的结果。 例如: <target name ="test"> ..... ..... </target> ..... ..... 我想知道目标“测试”执行所需的时间。您提到的中包含的任务 我使用它没有问题。首先定义一个秒表并指定名称。在目标结束时,使用total秒表操作。然后,经过的时间将存储到与创建秒表时使用的名称相同的

是否有一种方法可以知道目标在ant脚本中执行并将该时间存储在属性中所花费的时间。我已经通过了tstamp和秒表,但我没有得到正确的结果。 例如:

 <target name ="test">
   .....
   .....
  </target>

.....
.....
我想知道目标“测试”执行所需的时间。

您提到的中包含的任务

我使用它没有问题。首先定义一个秒表并指定名称。在目标结束时,使用
total
秒表操作。然后,经过的时间将存储到与创建秒表时使用的名称相同的属性中

<project name="Stopwatch">
  <!--
    Import Ant Contrib
  -->
  <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
      <pathelement location="lib/ant-contrib-1.0b3.jar"/>
    </classpath>
  </taskdef>

  <!-- 
    Demonstrates the use of the stopwatch task.
    Creates a stopwatch named "timer1", do some work and then take the total
    time. The time is then stored in property "timer1".    
  -->
  <target name="teststopwatch">
    <stopwatch name="timer1"/>
    <echo message="Hello" />
    <stopwatch name="timer1" action="total" />
    <echo message="Total time: ${timer1}" />
  </target>
</project>

您是否尝试过ant-v?我想设置目标在属性中执行所花费的时间值,因此没有尝试使用ant-v。此属性值将传递给其他目标
Buildfile: /home/[...]/StopwatchTest/build_stopwatch.xml
teststopwatch:
     [echo] Hello
[stopwatch] [timer1: 0.012 sec]
     [echo] Total time: 0.012 sec
BUILD SUCCESSFUL
Total time: 564 milliseconds