root/branches/streaming-rework/src/libstreaming/streamstatistics.cpp

Revision 266, 0.9 kB (checked in by pieterpalmers, 18 years ago)

- temporary commit

Line 
1 //
2 // C++ Implementation: streamstatistics
3 //
4 // Description:
5 //
6 //
7 // Author: Pieter Palmers, (C) 2006
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #include "streamstatistics.h"
13 #include <stdio.h>
14
15 namespace FreebobStreaming {
16
17 StreamStatistics::StreamStatistics()
18     : m_name("")
19     , m_count(0)
20     , m_average(0.0)
21     , m_min(0x7FFFFFFF)
22     , m_max(0)
23     , m_sum(0)
24 {
25
26 }
27
28
29 StreamStatistics::~StreamStatistics()
30 {
31 }
32
33 void StreamStatistics::mark(int value) {
34     if(value>m_max) m_max=value;
35     if(value<m_min) m_min=value;
36     m_count++;
37     m_sum+=value;
38     m_average=(1.0*m_sum)/(1.0*m_count);
39 }
40
41 void StreamStatistics::dumpInfo() {
42      printf("--- Stats for %s: min=%ld avg=%f max=%ld cnt=%ld sum=%ld\n",m_name.c_str(),
43          m_min,m_average,m_max,m_count,m_sum);
44 }
45
46 void StreamStatistics::reset() {
47     m_count=0;
48     m_average= 0.0;
49     m_min=0x7FFFFFFF;
50     m_max=0;
51     m_sum=0;
52 }
53
54 }
Note: See TracBrowser for help on using the browser.