Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 5177 invoked by uid 500); 1 Oct 2001 09:41:31 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 5168 invoked from network); 1 Oct 2001 09:41:30 -0000 Message-ID: <322043DFCB97D511BA7A00508B4AB4B07B366B@columbo.eaeurope.com> From: "Summerwill, Bob" To: ant-dev@jakarta.apache.org Subject: [PATCH] Task to time parts of the build Date: Mon, 1 Oct 2001 09:58:10 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C14A57.3248DA50" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C14A57.3248DA50 Content-Type: text/plain; charset="iso-8859-1" I originally sent this mail last Thursday, but it seems to have got lost somewhere along the way ... -----Original Message----- From: Summerwill, Bob [mailto:BSummerwill@europe.ea.com] Sent: 27 September 2001 18:23 To: ant-dev@jakarta.apache.org Subject: Task to time parts of the build I've written a task called "Timed" which can be used to time parts of the build. This is a trivial subclass of Sequential. I've written this as a new core task, though maybe it should be an optional task. I attach the .java source file and HTML documentation. As well as the new files, there are these one-liners ... --------------------------------------------------------------- docs/manual/coretasklist.html --------------------------------------------------------------- Timed
--------------------------------------------------------------- --------------------------------------------------------------- src/main/org/apache/tools/ant/taskdefs/defaults.properties --------------------------------------------------------------- timed=org.apache.tools.ant.taskdefs.Timed --------------------------------------------------------------- Cheers, Bob Summerwill Electronic Arts UK PS. Sorry they're not diffs - I'm behind a firewall, and CVS access to the Ant server is blocked at the moment. -----Original Message----- From: Summerwill, Bob [mailto:BSummerwill@europe.ea.com] Sent: 27 September 2001 14:57 To: ant-user@jakarta.apache.org Subject: RE: Timing parts of the build. I've written a new task to implement this, called Timed. This is a trivial subclass of Sequential. I've written this as a new core task, though maybe it should be optional. How should I submit this task to the project? There's a new .java file, the matching HTML documentation, and modifications to coretasklist.html and default.properties. Should I just send a [PATCH] e-mail to the ant-dev mailing list, containing the new code inline, with diffs for the changed files, and a brief explanation? Cheers, Bob -----Original Message----- From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com] Sent: 10 September 2001 13:24 To: ant-user@jakarta.apache.org Subject: Re: Timing parts of the build. You could create a task similar to Sequential that implements TaskContainer and have it do this pretty easily. It would give you the capability of timing tasks all within a target, not across targets. Actually it might be cleaner to just patch Sequential.java to do it automatically and avoid two "sequential" tasks out there. It seems like it'd only take a few lines of code. Erik ----- Original Message ----- From: "Summerwill, Bob" To: Sent: Monday, September 10, 2001 4:30 AM Subject: Timing parts of the build. > Has anyone got any recommendations on timing parts an Ant build? I'd like > to be able to place the timing for part of the build in a Ant property, so > it can be used in XSLT transforms, etc. > > > Pseudocode .... > > > > > > > > > > > > > > > > Is timing information available? Is there a simple way to do something > similar? > > > Cheers, > Bob > ------_=_NextPart_000_01C14A57.3248DA50 Content-Type: application/octet-stream; name="Timed.java" Content-Disposition: attachment; filename="Timed.java" /* * The Apache Software License, Version 1.1 * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Ant", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.BuildException; /** * A task container subclassed from Sequential, which times the tasks * which it contains. *

* @author Bob Summerwill * bsummerwill@ea.europe.com *

*/ public class Timed extends Sequential { private String property = null; public void setProperty(String property) { this.property = property; } public void execute() throws BuildException { if (this.property == null) { throw new BuildException("Attribute property is required.", this.location); } long startTime = System.currentTimeMillis(); super.execute(); long secondsElapsed = (System.currentTimeMillis() - startTime) / 1000; project.setProperty(this.property, secondsElapsed); } } } ------_=_NextPart_000_01C14A57.3248DA50 Content-Type: text/html; name="timed.html" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="timed.html" =0A= =0A= =0A= Ant User Manual=0A= =0A= =0A= =0A= =0A=

Timed

=0A=

Description

=0A=

Timed is a container task - it can contain other Ant tasks. It is a specialized version of sequential, which times the tasks which it contains. Like sequential, the nested tasks are executed in sequence. The timing information is in seconds.

Parameters

Attribute Description Required
property destination property for the timing. Yes

The timed task has a single compulsory attribute, which identifies the property which the elapsed time will be stored in. Any valid Ant task may be embedded within the timed task.

=0A=

Example

=0A=
=0A=
<timed property=3D"time.elapsed">=0A=
  <junit ...>=0A=
</timed>=0A=
<echo message=3D"JUnit took ${time.elapsed} =
seconds">=0A=
=0A= =0A=
=0A=

Copyright © 2000,2001 Apache Software = Foundation. All rights=0A= Reserved.

=0A= =0A= =0A= =0A= ------_=_NextPart_000_01C14A57.3248DA50--