~ubuntu-branches/ubuntu/trusty/ticcutils/trusty-proposed

« back to all changes in this revision

Viewing changes to include/ticcutils/Timer.h

  • Committer: Package Import Robot
  • Author(s): Ko van der Sloot
  • Date: 2013-04-18 15:14:58 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130418151458-o3zeb8f0676003y3
Tags: 0.4-3
debian/control: also added Replaces: libticcutils1-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  $Id: Timer.h 15863 2013-04-02 10:59:38Z sloot $
 
3
  $URL: https://ilk.uvt.nl/svn/sources/libticcutils/trunk/include/ticcutils/Timer.h $
 
4
 
 
5
  Copyright (c) 1998 - 2013
 
6
  ILK   - Tilburg University
 
7
  CLiPS - University of Antwerp
 
8
 
 
9
  This file is part of ticcutils
 
10
 
 
11
  ticcutils is free software; you can redistribute it and/or modify
 
12
  it under the terms of the GNU General Public License as published by
 
13
  the Free Software Foundation; either version 3 of the License, or
 
14
  (at your option) any later version.
 
15
 
 
16
  ticcutils is distributed in the hope that it will be useful,
 
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
  GNU General Public License for more details.
 
20
 
 
21
  You should have received a copy of the GNU General Public License
 
22
  along with this program; if not, see <http://www.gnu.org/licenses/>.
 
23
 
 
24
  For questions and suggestions, see:
 
25
      http://ilk.uvt.nl/software.html
 
26
  or send mail to:
 
27
      timbl@uvt.nl
 
28
*/
 
29
#ifndef TICC_TIMER_H
 
30
#define TICC_TIMER_H
 
31
 
 
32
#include <cstdlib>
 
33
#include <sys/time.h>
 
34
 
 
35
namespace TiCC {
 
36
  class Timer {
 
37
  public:
 
38
    friend std::ostream& operator << ( std::ostream& os, const Timer& T );
 
39
    Timer(){ reset(); };
 
40
    void reset(){ myTime.tv_sec=0; myTime.tv_usec=0; };
 
41
    void start(){
 
42
      gettimeofday( &startTime, 0 );
 
43
    };
 
44
    void stop();
 
45
    unsigned int secs() { stop(); return myTime.tv_sec; };
 
46
    std::string toString();
 
47
    static std::string now();
 
48
  private:
 
49
    timeval startTime;
 
50
    timeval myTime;
 
51
  };
 
52
 
 
53
}
 
54
 
 
55
#endif // TICC_TIMER_H