📄 tvtimer.h
字号:
/* COPYRIGHT NOTICE This material was developed by Christos Faloutsos and King-Ip Linat the University of Maryland, College Park, Department of Computer Science.Permission is granted to copy this software, to redistribute iton a nonprofit basis, and to use it for any purpose, subject tothe following restrictions and understandings. 1. Any copy made of this software must include this copyright noticein full. 2. All materials developed as a consequence of the use of thissoftware shall duly acknowledge such use, in accordance with the usualstandards of acknowledging credit in academic research. 3. The authors have made no warranty or representation that theoperation of this software will be error-free or suitable for anyapplication, and they are under under no obligation to provide anyservices, by way of maintenance, update, or otherwise. The softwareis an experimental prototype offered on an as-is basis. 4. Redistribution for profit requires the express, written permissionof the authors. */// Author : $Author$// Date : $Date$// Id : $Id$#ifndef _TIMER_H#define _TIMER_H#include <iostream.h>extern "C" {#include <sys/resource.h>#include <sys/time.h>}class Timer { private: static Timer _global; // Global timer char _state; // current state of timer struct rusage _ru_start, _ru_sum; // start and sum for rusage timer struct timeval _tp_start, _tp_sum; // start and sum for real-time timer char *_name; // Timers may be named public: enum { kRunning = 0x01 }; static Timer global(); // Return a copy of the global timer Timer(char *name = (char *) NULL, char mode = 0); // Creates new timer cleared at zero (dflt: stopped) float real(); float system(); float user(); char* name(); char state(); void sync(); // Synchronizes timer with the "global" timer void reset(); // Resets timer to zero void stop(); // Stops timer from counting void run(); // Lets timer continue counting // Display current value of time friend ostream& operator<<(ostream &os, Timer &t);};inline Timer Timer::global(){ return _global;}inline char* Timer::name(){ return _name;}inline char Timer::state(){ return _state;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -