SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Time.cpp
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 #include <shogun/lib/Time.h>
12 #include <shogun/io/SGIO.h>
13 #include <shogun/lib/common.h>
14 #include <shogun/base/SGObject.h>
15 
16 using namespace shogun;
17 
18 CTime::CTime(bool st)
19 : CSGObject()
20 {
21  start_time=0;
22  stop_time=0;
23  start_runtime=0;
24 
25  if (st)
26  start();
27 }
28 
30 {
31 }
32 
33 clock_t CTime::cur_runtime(bool verbose)
34 {
35  clock_t cur_time=clock();
36  if (verbose)
37  SG_PRINT("current %ld\n", (int64_t) cur_time)
38  return cur_time;
39 }
40 
41 clock_t CTime::cur_runtime_diff(bool verbose)
42 {
43  clock_t diff=clock()-start_runtime;
44  if (verbose)
45  SG_PRINT("current diff %ld\n", (int64_t) diff)
46  return diff;
47 }
48 
50 {
51  float64_t diff_s = ((float64_t)(clock() - start_runtime)) / CLOCKS_PER_SEC;
52  if (verbose)
53  SG_PRINT("%2.1f seconds\n", diff_s)
54 
55  return diff_s;
56 }
57 
58 
59 float64_t CTime::start(bool verbose)
60 {
62 
63  if (verbose)
64  SG_PRINT("start %ld\n", (int64_t) start_time)
65  return start_time;
66 }
67 
69 {
70  float64_t diff_s = get_curtime()-start_time;
71  if (verbose)
72  SG_PRINT("%2.1f seconds\n", diff_s)
73 
74  return diff_s;
75 }
76 
78 {
79  float64_t diff_s = stop_time - start_time;
80  if (verbose)
81  SG_PRINT("%2.1f seconds\n", diff_s)
82 
83  return diff_s;
84 }
85 
86 float64_t CTime::stop(bool verbose)
87 {
89 
90  if (verbose)
91  SG_PRINT("stop %ld\n", (int64_t) stop_time)
92  return stop_time;
93 }

SHOGUN Machine Learning Toolbox - Documentation