/usr/include/gamera/utility.hpp is in python-gamera-dev 3.3.3-2+deb7u1.
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 | /*
*
* Copyright (C) 2001-2005 Ichiro Fujinaga, Michael Droettboom, and Karl MacMillan
*
* 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 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <time.h>
//#include <sys/time.h>
//#include <sys/types.h>
#include "gamera.hpp"
#ifndef kwm07192002_utility
#define kwm07192002_utility
namespace Gamera {
inline void byte_swap32(unsigned char *ptr) {
register unsigned char val;
val = *(ptr);
*(ptr) = *(ptr+3);
*(ptr+3) = val;
ptr += 1;
val = *(ptr);
*(ptr) = *(ptr+1);
*(ptr+1) = val;
}
class Clocker {
public:
void start();
void stop();
float seconds();
float microseconds();
private:
clock_t _start;
clock_t _end;
};
inline void Clocker::start() {
_start = clock();
}
inline void Clocker::stop() {
_end = clock();
}
inline float Clocker::seconds() {
return ((float)(_end - _start) / (float)CLOCKS_PER_SEC);
}
inline float Clocker::microseconds() {
return ((float)((_end - _start) / (float)CLOCKS_PER_SEC) * 1000000);
}
#if 0
/**
Alternative to Clocker, which wraps after about 35.79 minutes
Clocker measures CPU time, Timer measures real time.
Clocker resolution is 10ms on Linux/Intel
Timer resolution is about 10 microseconds
If a finer resolution is needed checkout POSIX.4 clock_gettime()
01/06/06 IF started
6/7/01 KWM integrated into Gamera
*/
class Timer {
public:
void start();
void stop();
float seconds();
Timer();
private:
struct timeval _start;
struct timeval _end;
struct timezone tz; // not used
};
Timer::Timer() {
_start.tv_sec = _start.tv_usec = 0;
_end.tv_sec = _end.tv_usec = 0;
}
inline void Timer::start() {
gettimeofday(&_start, &tz);
}
inline void Timer::stop() {
gettimeofday(&_end, &tz);
}
inline float Timer::seconds() {
return ((_end.tv_sec - _start.tv_sec) +
(_end.tv_usec - _start.tv_usec) / 1000000.);
}
#endif
}; // namespace Gamera
#endif
|