/usr/include/kmer/util/speedCounter.H is in libkmer-dev 0~20150903+r2013-3.
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 | #ifndef SPEEDCOUNTER_H
#define SPEEDCOUNTER_H
#include <stdio.h>
class speedCounter {
public:
// fmt specifies the status format. An example:
// " %8f [unit]things (%8.5f [unit]things/sec)\r"
//
speedCounter(char const *fmt,
double unit,
uint64 freq,
bool enabled=true);
~speedCounter();
void enableSpinner(void) { _spin = true; };
void enableLiner(void) { _line = true; };
bool tick(void) {
if (_enabled && ((++_count & _freq) == uint64ZERO)) {
double v = _count / _unit;
if (_spin) fputs(_spinr[_draws % 4], stderr);
if (_line) fputs(_liner[_draws % 19], stderr);
_draws++;
fprintf(stderr, _fmt, v, v / (getTime() - _startTime));
fflush(stderr);
return(true);
}
return(false);
};
bool tick(uint64 increment) {
if (_enabled == false)
return(false);
_count += increment;
if ((_count & _freq) == uint64ZERO) {
double v = _count / _unit;
if (_spin) fputs(_spinr[_draws % 4], stderr);
if (_line) fputs(_liner[_draws % 19], stderr);
_draws++;
fprintf(stderr, _fmt, v, v / (getTime() - _startTime));
fflush(stderr);
return(true);
}
return(false);
};
void finish(void) {
if (_enabled && (_count >= _freq)) {
double v = _count / _unit;
if (_spin) fputs(_spinr[_draws % 4], stderr);
if (_line) fputs(_liner[_draws % 19], stderr);
fprintf(stderr, _fmt, v, v / (getTime() - _startTime));
fprintf(stderr, "\n");
fflush(stderr);
}
_count = 0;
};
private:
static const char *_spinr[4];
static const char *_liner[19];
uint64 _count;
uint64 _draws;
double _unit;
uint64 _freq;
double _startTime;
char const *_fmt;
bool _spin;
bool _line;
bool _enabled;
};
#endif // SPEEDCOUNTER_H
|