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

Revision 445, 1.6 kB (checked in by pieterpalmers, 15 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #include "StreamStatistics.h"
25 #include <stdio.h>
26
27 namespace Streaming {
28
29 StreamStatistics::StreamStatistics()
30     : m_name("")
31     , m_count(0)
32     , m_average(0.0)
33     , m_min(0x7FFFFFFF)
34     , m_max(0)
35     , m_sum(0)
36 {
37
38 }
39
40
41 StreamStatistics::~StreamStatistics()
42 {
43 }
44
45 void StreamStatistics::mark(int value) {
46     if(value>m_max) m_max=value;
47     if(value<m_min) m_min=value;
48     m_count++;
49     m_sum+=value;
50     m_average=(1.0*m_sum)/(1.0*m_count);
51 }
52
53 void StreamStatistics::dumpInfo() {
54      printf("--- Stats for %s: min=%ld avg=%f max=%ld cnt=%ld sum=%ld\n",m_name.c_str(),
55          m_min,m_average,m_max,m_count,m_sum);
56 }
57
58 void StreamStatistics::reset() {
59     m_count=0;
60     m_average= 0.0;
61     m_min=0x7FFFFFFF;
62     m_max=0;
63     m_sum=0;
64 }
65
66 }
Note: See TracBrowser for help on using the browser.