SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
lib
Time.cpp
浏览该文件的文档.
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
#include <
shogun/lib/Time.h
>
12
#include <
shogun/io/SGIO.h
>
13
#include <
shogun/lib/common.h
>
14
15
using namespace
shogun;
16
17
CTime::CTime
(
bool
st)
18
:
CSGObject
()
19
{
20
start_time
=0;
21
stop_time
=0;
22
start_runtime
=0;
23
24
if
(st)
25
start
();
26
}
27
28
CTime::~CTime
()
29
{
30
}
31
32
clock_t
CTime::cur_runtime
(
bool
verbose)
33
{
34
clock_t cur_time=clock();
35
if
(verbose)
36
SG_PRINT
(
"current %ld\n"
, (int64_t) cur_time)
37
return
cur_time;
38
}
39
40
clock_t
CTime::cur_runtime_diff
(
bool
verbose)
41
{
42
clock_t diff=clock()-
start_runtime
;
43
if
(verbose)
44
SG_PRINT
(
"current diff %ld\n"
, (int64_t) diff)
45
return
diff;
46
}
47
48
float64_t
CTime::cur_runtime_diff_sec
(
bool
verbose)
49
{
50
float64_t
diff_s = ((
float64_t
)(clock() -
start_runtime
)) / CLOCKS_PER_SEC;
51
if
(verbose)
52
SG_PRINT
(
"%2.1f seconds\n"
, diff_s)
53
54
return
diff_s;
55
}
56
57
58
float64_t
CTime::start
(
bool
verbose)
59
{
60
start_time
=
get_curtime
();
61
62
if
(verbose)
63
SG_PRINT
(
"start %ld\n"
, (int64_t)
start_time
)
64
return
start_time
;
65
}
66
67
float64_t
CTime::cur_time_diff
(
bool
verbose)
68
{
69
float64_t
diff_s =
get_curtime
()-
start_time
;
70
if
(verbose)
71
SG_PRINT
(
"%2.1f seconds\n"
, diff_s)
72
73
return
diff_s;
74
}
75
76
float64_t
CTime::time_diff_sec
(
bool
verbose)
77
{
78
float64_t
diff_s =
stop_time
-
start_time
;
79
if
(verbose)
80
SG_PRINT
(
"%2.1f seconds\n"
, diff_s)
81
82
return
diff_s;
83
}
84
85
float64_t
CTime::stop
(
bool
verbose)
86
{
87
stop_time
=
get_curtime
();
88
89
if
(verbose)
90
SG_PRINT
(
"stop %ld\n"
, (int64_t)
stop_time
)
91
return
stop_time
;
92
}
SHOGUN
机器学习工具包 - 项目文档