timer.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand        --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------


class TIMER

class TIMER is -- This class provides for a program timer facility by noting the start -- time of some activity and the finish time and taking a difference to -- determine how long the activity lasted. -- Version 1.3 Oct 98. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 10 Dec 96 kh Original from distribution library -- 20 Apr 97 kh Revised NOT to use built-in. -- 16 Jun 97 kh Revised after OS service interface change. -- 29 Oct 98 kh Refined to use TIME_STAMP. private attr time_at_start : TIME_STAMP ; create : SAME is -- This routine creates the timer object but does not 'start' the clock. return new end ; start is -- This routine begins the timer running. time_at_start := TIME_STAMP::now end ; clear is -- This routine clears the timer for further use in another timing 'run'. start end ; elapsed : ELAPSED pre ~(time_at_start = TIME_STAMP::create(0,0)) post true -- but could be 'zero'! ~void(result) is -- This routine returns the elapsed clock time since calling "start". -- Precision is not guaranteed beyond seconds although the expected -- resolution should be milliseconds -- this depends on the underlying system -- clock. return TIME_STAMP::now - time_at_start end ; end ; -- TIMER