Sign in
Register
Home
Projects
Help
Search
:
SV Libraries
»
SV Core Library
Overview
Members
Activity
Issues
Repository
Code docs
svcore
1.9
Main Page
Namespaces
Classes
Files
File List
File Members
base
HitCount.h
Go to the documentation of this file.
1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3
/*
4
Sonic Visualiser
5
An audio file viewer and annotation editor.
6
Centre for Digital Music, Queen Mary, University of London.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License as
10
published by the Free Software Foundation; either version 2 of the
11
License, or (at your option) any later version. See the file
12
COPYING included with this distribution for more information.
13
*/
14
15
#ifndef HIT_COUNT_H
16
#define HIT_COUNT_H
17
18
#include <string>
19
#include <iostream>
20
24
#ifndef NO_HIT_COUNTS
25
26
class
HitCount
27
{
28
public
:
29
HitCount
(std::string name) :
30
m_name
(name),
31
m_hit
(0),
32
m_partial
(0),
33
m_miss
(0)
34
{ }
35
36
~HitCount
() {
37
using namespace
std
;
38
int
total =
m_hit
+
m_partial
+
m_miss
;
39
cerr <<
"Hit count: "
<<
m_name
<<
": "
;
40
if
(
m_partial
> 0) {
41
cerr <<
m_hit
<<
" hits, "
<<
m_partial
<<
" partial, "
42
<< m_miss <<
" misses"
;
43
}
else
{
44
cerr <<
m_hit
<<
" hits, "
<< m_miss <<
" misses"
;
45
}
46
if
(total > 0) {
47
if
(
m_partial
> 0) {
48
cerr <<
" ("
<< ((
m_hit
* 100.0) / total) <<
"%, "
49
<< ((
m_partial
* 100.0) / total) <<
"%, "
50
<< ((m_miss * 100.0) / total) <<
"%)"
;
51
}
else
{
52
cerr <<
" ("
<< ((
m_hit
* 100.0) / total) <<
"%, "
53
<< ((m_miss * 100.0) / total) <<
"%)"
;
54
}
55
}
56
cerr << endl;
57
}
58
59
void
hit
() { ++
m_hit
; }
60
void
partial
() { ++
m_partial
; }
61
void
miss
() { ++
m_miss
; }
62
63
private
:
64
std::string
m_name
;
65
int
m_hit
;
66
int
m_partial
;
67
int
m_miss
;
68
};
69
70
#else // NO_HIT_COUNTS
71
72
class
HitCount
73
{
74
public
:
75
HitCount
(std::string) {}
76
77
void
hit
() {}
78
void
partial
() {}
79
void
miss
() {}
80
};
81
82
#endif
83
84
#endif
HitCount::HitCount
HitCount(std::string name)
Definition:
HitCount.h:29
std
HitCount::partial
void partial()
Definition:
HitCount.h:60
HitCount
Profile class for counting cache hits and the like.
Definition:
HitCount.h:26
HitCount::m_miss
int m_miss
Definition:
HitCount.h:67
HitCount::m_partial
int m_partial
Definition:
HitCount.h:66
HitCount::~HitCount
~HitCount()
Definition:
HitCount.h:36
HitCount::miss
void miss()
Definition:
HitCount.h:61
HitCount::m_hit
int m_hit
Definition:
HitCount.h:65
HitCount::m_name
std::string m_name
Definition:
HitCount.h:64
HitCount::hit
void hit()
Definition:
HitCount.h:59
Generated by
1.8.11
Loading...