timer.h #1

  • //
  • guest/
  • perforce_software/
  • p4/
  • 2014.2/
  • sys/
  • timer.h
  • View
  • Commits
  • Open Download .zip Download (1 KB)
/*
 * Copyright 2001 Perforce Software.  All rights reserved.
 *
 * This file is part of Perforce - the FAST SCM System.
 */

/*
 * Timer - lapse timer
 *
 * Timer is a OS specific object that measures lapse time.
 *
 * Classes:
 *	Timer - lapse and CPU timer
 *	FmtMs() - format milliseconds with varying precision
 *
 * Public methods:
 *	Timer::Start() - restart the timer
 *	Timer::Message() - format an OS-specific resource usage message
 *	Timer::Time() - return MS since Start()
 *	Timer::Reset() - restart the timer to the time of the last check
 */

class StrBuf;

class StrMs : public StrPtr {

    public:
		StrMs( int ms );

    private:

	char	buf[ 24 ];

} ;
 
class Timer {

    public:
	void	        Start();
        void	        Message( StrBuf &msg ) 
                        { msg << StrMs( Time() ) << "s"; }
        int	        Time();
	void		Restart();

        const StrPtr &	Fmt( StrBuf &b ) const;
        void		Parse( const StrPtr &v );

    private:

	struct timer {
		long	sec;
		long	usec;
	} start, stop;

	static void Set( struct timer &t );

} ;

# Change User Description Committed
#2 15901 Matt Attaway Clean up code to fit modern Workshop naming standards
#1 12189 Matt Attaway Initial (and much belated) drop of 2014.2 p4 source code