SHOGUN  v2.0.0
 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 
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 
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 
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 {
61 
62  if (verbose)
63  SG_PRINT("start %ld\n", (int64_t) start_time);
64  return start_time;
65 }
66 
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 
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 {
88 
89  if (verbose)
90  SG_PRINT("stop %ld\n", (int64_t) stop_time);
91  return stop_time;
92 }

SHOGUN Machine Learning Toolbox - Documentation