root/branches/streaming-rework/src/libutil/StreamStatistics.cpp

Revision 419, 1.7 kB (checked in by pieterpalmers, 17 years ago)

namespace simplification

Line 
1 /* $Id$ */
2
3 /*
4  *   FreeBob Streaming API
5  *   FreeBob = Firewire (pro-)audio for linux
6  *
7  *   http://freebob.sf.net
8  *
9  *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>
10  *
11  *   This program is free software {} you can redistribute it and/or modify
12  *   it under the terms of the GNU General Public License as published by
13  *   the Free Software Foundation {} either version 2 of the License, or
14  *   (at your option) any later version.
15  *
16  *   This program is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY {} without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *   GNU General Public License for more details.
20  *
21  *   You should have received a copy of the GNU General Public License
22  *   along with this program {} if not, write to the Free Software
23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  *
26  *
27  */
28
29 #include "StreamStatistics.h"
30 #include <stdio.h>
31
32 namespace Streaming {
33
34 StreamStatistics::StreamStatistics()
35     : m_name("")
36     , m_count(0)
37     , m_average(0.0)
38     , m_min(0x7FFFFFFF)
39     , m_max(0)
40     , m_sum(0)
41 {
42
43 }
44
45
46 StreamStatistics::~StreamStatistics()
47 {
48 }
49
50 void StreamStatistics::mark(int value) {
51     if(value>m_max) m_max=value;
52     if(value<m_min) m_min=value;
53     m_count++;
54     m_sum+=value;
55     m_average=(1.0*m_sum)/(1.0*m_count);
56 }
57
58 void StreamStatistics::dumpInfo() {
59      printf("--- Stats for %s: min=%ld avg=%f max=%ld cnt=%ld sum=%ld\n",m_name.c_str(),
60          m_min,m_average,m_max,m_count,m_sum);
61 }
62
63 void StreamStatistics::reset() {
64     m_count=0;
65     m_average= 0.0;
66     m_min=0x7FFFFFFF;
67     m_max=0;
68     m_sum=0;
69 }
70
71 }
Note: See TracBrowser for help on using the browser.