/usr/include/shogun/lib/Time.h is in libshogun-dev 1.1.0-4ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 1999-2009 Soeren Sonnenburg
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
*/
#ifndef __TIME_H__
#define __TIME_H__
#include <sys/time.h>
#include <time.h>
#include <shogun/lib/common.h>
#include <shogun/io/SGIO.h>
#include <shogun/base/SGObject.h>
namespace shogun
{
/** @brief Class Time that implements a stopwatch based on either cpu time or wall
* clock time. */
class CTime : public CSGObject
{
public:
/** constructor
*
* @param start if time measurement shall be started
*/
CTime(bool start=true);
virtual ~CTime();
/** get current cpu runtime
*
* @param verbose if time shall be printed
* @return current cpu runtime
*/
clock_t cur_runtime(bool verbose=false);
/** get time difference between start and NOW
*
* @param verbose if time difference shall be printed
* @return time difference between start and NOW
*/
clock_t cur_runtime_diff(bool verbose=false);
/** get time difference between start and NOW in seconds
* (wall clock time)
*
* @param verbose if time difference shall be printed
* @return time difference between start and NOW in seconds
*/
float64_t cur_runtime_diff_sec(bool verbose=false);
/** start the counter
*
* @param verbose if start time shall be printed
* @return start time in seconds
*/
float64_t start(bool verbose=false);
/** get time difference between start and NOW in seconds
* (wall clock time)
*
* @param verbose if time difference shall be printed
* @return time difference between start and NOW in seconds
*/
float64_t cur_time_diff(bool verbose=false);
/** get time difference between start and stop in seconds
*
* @param verbose if time difference shall be printed
* @return time difference between start and stop in seconds
*/
float64_t time_diff_sec(bool verbose=false);
/** stop the counter
* @param verbose if stop time shall be printed
* @return stop time in seconds
*/
float64_t stop(bool verbose=false);
/** get runtime
*
* @return runtime
*/
static float64_t get_runtime()
{
clock_t start_runtime = clock();
return ((float64_t) start_runtime)/CLOCKS_PER_SEC;
}
/** get current time in seconds
*
* @return current time in seconds
*/
static float64_t get_curtime()
{
timeval tv;
if (gettimeofday(&tv, NULL)==0)
return tv.tv_sec+(tv.tv_usec*1e-6);
else
return 0.0;
}
/** @return object name */
inline virtual const char* get_name() const { return "Time"; }
protected:
/** start runtime */
clock_t start_runtime;
/** start time */
float64_t start_time;
/** stop time */
float64_t stop_time;
};
}
#endif
|