SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
lib
Time.h
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 3 of the License, or
5
* (at your option) any later version.
6
*
7
* Written (W) 1999-2009 Soeren Sonnenburg
8
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#ifndef __TIME_H__
12
#define __TIME_H__
13
14
#include <sys/time.h>
15
#include <time.h>
16
17
#include <
shogun/lib/common.h
>
18
#include <
shogun/io/SGIO.h
>
19
#include <
shogun/base/SGObject.h
>
20
21
namespace
shogun
22
{
25
class
CTime
:
public
CSGObject
26
{
27
public
:
32
CTime
(
bool
start
=
true
);
33
virtual
~CTime
();
34
40
clock_t
cur_runtime
(
bool
verbose=
false
);
41
47
clock_t
cur_runtime_diff
(
bool
verbose=
false
);
48
55
float64_t
cur_runtime_diff_sec
(
bool
verbose=
false
);
56
62
float64_t
start
(
bool
verbose=
false
);
63
70
float64_t
cur_time_diff
(
bool
verbose=
false
);
71
77
float64_t
time_diff_sec
(
bool
verbose=
false
);
78
83
float64_t
stop
(
bool
verbose=
false
);
84
89
static
float64_t
get_runtime
()
90
{
91
clock_t
start_runtime
= clock();
92
return
((
float64_t
) start_runtime)/CLOCKS_PER_SEC;
93
}
94
99
static
float64_t
get_curtime
()
100
{
101
timeval tv;
102
if
(gettimeofday(&tv, NULL)==0)
103
return
tv.tv_sec+(tv.tv_usec*1e-6);
104
else
105
return
0.0;
106
}
107
109
inline
virtual
const
char
*
get_name
()
const
{
return
"Time"
; }
110
111
protected
:
113
clock_t
start_runtime
;
114
116
float64_t
start_time
;
118
float64_t
stop_time
;
119
};
120
}
121
#endif
SHOGUN
Machine Learning Toolbox - Documentation