root/trunk/libffado/src/libutil/StreamStatistics.cpp

Revision 742, 2.1 kB (checked in by ppalmers, 16 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "StreamStatistics.h"
25 #include <stdio.h>
26
27 namespace Streaming {
28 IMPL_DEBUG_MODULE( StreamStatistics, StreamStatistics, DEBUG_LEVEL_VERBOSE );
29
30 StreamStatistics::StreamStatistics()
31     : m_name("")
32     , m_count(0)
33     , m_average(0.0)
34     , m_min(0x7FFFFFFF)
35     , m_max(0)
36     , m_sum(0)
37 {
38     reset();
39 }
40
41 void StreamStatistics::mark(int value) {
42     if(value>m_max) m_max=value;
43     if(value<m_min) m_min=value;
44     m_count++;
45     m_sum+=value;
46     m_average=(1.0*m_sum)/(1.0*m_count);
47 }
48
49 void StreamStatistics::signal(unsigned int val) {
50     if (val <= MAX_SIGNAL_VALUE) {
51         m_signalled[val]++;
52     }
53 }
54
55 void StreamStatistics::dumpInfo() {
56     debugOutputShort( DEBUG_LEVEL_VERBOSE,
57                       "--- Stats for %s: min=%ld avg=%f max=%ld cnt=%ld sum=%ld\n",
58                       m_name.c_str(), m_min, m_average, m_max, m_count, m_sum);
59     debugOutputShort( DEBUG_LEVEL_VERBOSE, "    Signal stats\n");
60     for (unsigned int i=0;i <= MAX_SIGNAL_VALUE; i++) {
61         debugOutputShort(DEBUG_LEVEL_VERBOSE,
62                          "     Stats for %3u: %8u\n",
63                          i, m_signalled[i]);
64     }
65 }
66
67 void StreamStatistics::reset() {
68     m_count=0;
69     m_average= 0.0;
70     m_min=0x7FFFFFFF;
71     m_max=0;
72     m_sum=0;
73
74     for (unsigned int i=0;i <= MAX_SIGNAL_VALUE; i++) {
75         m_signalled[i]=0;
76     }
77 }
78
79 }
Note: See TracBrowser for help on using the browser.