home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #ifndef _timer_
- #define _timer_
-
- #include <sys/time.h>
-
- /*
- * A usefull timer class. Start and stop are self explanetory.
- * Elapse will return seconds since last start if the timer is running or
- * seconds between last start and stop if the timer is not running.
- */
-
- #ifdef __cplusplus
-
- class timer
- {
- public:
- timer();
- void start();
- virtual void stop();
- float elapse();
- float elapseStart(); // atomic version of elapse(); start();
- private:
- struct timeval beginTime, endTime;
- int running;
- };
-
- class totalTimer : public timer
- {
- public:
- totalTimer(char *);
- float getTotal();
- int getCount();
- virtual void stop();
-
- char * description;
- private:
- int count;
- float totalTime;
- };
-
- class perfTimer : public totalTimer
- {
- public:
- perfTimer(char * d) : totalTimer(d) {}
- ~perfTimer();
- void print();
- };
-
- /*
- * Useful demo routines for showing the current frame/polygon/... rate.
- * Simply call showFrameRate just before swapbuffers to get the frame rate.
- * Disable the rate display with setFrameRateActive(FALSE). To show something
- * other than frame rate (eg. polygon rate) call setFrameRateMultiplier(foo)
- * before showFrameRate. Foo is the quantity of whatevery is to be measured.
- * Call setFrameRateDescription("%5.2f Whoopies/sec") to change the description
- * of the rate display. The string given is used in an sprintf call with one
- * float argument given. As the measured rate changes, the rate displayed
- * will approach and become this rate in about one second. To change this
- * time call setFrameRateConvergence(t), where t is time in seconds.
- */
-
-
- extern "C" {
-
- #endif
-
- void showFrameRate();
- void setFrameRateMultiplier(float);
- void setFrameRateDescription(char *);
- void setFrameRateActive(int);
- void setFrameRateConvergence(float);
-
- #ifdef __cplusplus
- }
- #endif
- #endif
-