-
Notifications
You must be signed in to change notification settings - Fork 2
/
snTimer.h
75 lines (62 loc) · 2.18 KB
/
snTimer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __SNTIMER__
#define __SNTIMER__
#include "snString.h"
#ifdef WIN32
#include <windows.h>
#define longinttype __int64
#else
#include <sys/time.h>
#define longinttype timeval
#endif
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.html>.
Author: Helge Mathee [email protected]
Company: Studio Nest (TM)
Date: 2010 / 09 / 21
*/
/**
* snEssence is the shared namespace between all classes within the snEssence library.
*/
namespace snEssence
{
/**
* A cross-OS class for measuring times in miliseconds for code complexity improvements.
*/
class snTimer
{
private:
longinttype m_iStartTime;
longinttype m_iEndTime;
double m_dFrequeny;
bool m_bRunning;
snString m_strMessage;
public:
/// Default constructor, starts the timer also.
snTimer();
/// Default constructor, sets the message and starts the timer also.
snTimer(const snString & in_strMessage);
/// Default destructor. If the timer is still running it will print the
/// timer message to the STD::OUT.
~snTimer();
/// Get the time spent in miliseconds.
long GetMiliSeconds() const;
/// Get a string message including the miliseconds spent.
snString GetTimerMessage() const;
// setters
void SetTimerMessage(const snString & in_strMessage);
/// Start the timer another time.
void Start();
/// Stop the timer (should not be necessary).
void Stop();
};
}
#endif