comparison base/HitCount.h @ 1429:48e9f538e6e9

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 6974bd4efdb5
children 410819150cd3
comparison
equal deleted inserted replaced
1428:87ae75da6527 1429:48e9f538e6e9
23 */ 23 */
24 class HitCount 24 class HitCount
25 { 25 {
26 public: 26 public:
27 HitCount(std::string name) : 27 HitCount(std::string name) :
28 m_name(name), 28 m_name(name),
29 m_hit(0), 29 m_hit(0),
30 m_partial(0), 30 m_partial(0),
31 m_miss(0) 31 m_miss(0)
32 { } 32 { }
33 33
34 ~HitCount() { 34 ~HitCount() {
35 #ifndef NO_HIT_COUNTS 35 #ifndef NO_HIT_COUNTS
36 using namespace std; 36 using namespace std;
37 int total = m_hit + m_partial + m_miss; 37 int total = m_hit + m_partial + m_miss;
38 cerr << "Hit count: " << m_name << ": "; 38 cerr << "Hit count: " << m_name << ": ";
39 if (m_partial > 0) { 39 if (m_partial > 0) {
40 cerr << m_hit << " hits, " << m_partial << " partial, " 40 cerr << m_hit << " hits, " << m_partial << " partial, "
41 << m_miss << " misses"; 41 << m_miss << " misses";
42 } else { 42 } else {
43 cerr << m_hit << " hits, " << m_miss << " misses"; 43 cerr << m_hit << " hits, " << m_miss << " misses";
44 } 44 }
45 if (total > 0) { 45 if (total > 0) {
46 if (m_partial > 0) { 46 if (m_partial > 0) {
47 cerr << " (" << ((m_hit * 100.0) / total) << "%, " 47 cerr << " (" << ((m_hit * 100.0) / total) << "%, "
48 << ((m_partial * 100.0) / total) << "%, " 48 << ((m_partial * 100.0) / total) << "%, "
49 << ((m_miss * 100.0) / total) << "%)"; 49 << ((m_miss * 100.0) / total) << "%)";
50 } else { 50 } else {
51 cerr << " (" << ((m_hit * 100.0) / total) << "%, " 51 cerr << " (" << ((m_hit * 100.0) / total) << "%, "
52 << ((m_miss * 100.0) / total) << "%)"; 52 << ((m_miss * 100.0) / total) << "%)";
53 } 53 }
54 } 54 }
55 cerr << endl; 55 cerr << endl;
56 #endif 56 #endif
57 } 57 }
58 58
59 void hit() { ++m_hit; } 59 void hit() { ++m_hit; }
60 void partial() { ++m_partial; } 60 void partial() { ++m_partial; }