OSDN Git Service

WebGUIのレスポンスが悪かったのを修正
[peercast-im/PeerCastIM.git] / PeerCast.root / PeerCast / core / common / stats.h
1 // ------------------------------------------------
2 // File : stats.h
3 // Date: 4-apr-2002
4 // Author: giles
5 // Desc: 
6 //
7 // (c) 2002 peercast.org
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 2 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
20 #ifndef _STATS_H
21 #define _STATS_H
22
23 // ------------------------------------------------------
24 class Stats
25 {
26 public:
27
28         void    clear();
29         void    update();
30
31         enum STAT
32         {
33                 NONE,
34
35                 PACKETSSTART,
36                 NUMQUERYIN,NUMQUERYOUT,
37                 NUMPINGIN,NUMPINGOUT,
38                 NUMPONGIN,NUMPONGOUT,
39                 NUMPUSHIN,NUMPUSHOUT,
40                 NUMHITIN,NUMHITOUT,
41                 NUMOTHERIN,NUMOTHEROUT,
42                 NUMDROPPED,
43                 NUMDUP,
44                 NUMACCEPTED,
45                 NUMOLD,
46                 NUMBAD,
47                 NUMHOPS1,NUMHOPS2,NUMHOPS3,NUMHOPS4,NUMHOPS5,NUMHOPS6,NUMHOPS7,NUMHOPS8,NUMHOPS9,NUMHOPS10,
48                 NUMPACKETSIN,
49                 NUMPACKETSOUT,
50                 NUMROUTED,
51                 NUMBROADCASTED,
52                 NUMDISCARDED,
53                 NUMDEAD,
54                 PACKETDATAIN,
55                 PACKETDATAOUT,
56                 PACKETSEND,             
57                 
58
59                 BYTESIN,
60                 BYTESOUT,
61                 LOCALBYTESIN,
62                 LOCALBYTESOUT,
63
64                 MAX
65         };
66
67         bool    writeVariable(class Stream &,const class String &);
68
69         void    clearRange(STAT s, STAT e)
70         {
71                 for(int i=s; i<=e; i++)
72                         current[i] = 0;
73         }
74         void    clear(STAT s) {current[s]=0;}
75         void    add(STAT s,int n=1) {current[s]+=n;}
76         unsigned int getPerSecond(STAT s) {return perSec[s];}
77         unsigned long long int getCurrent(STAT s) {return current[s];}
78
79         unsigned long long int  current[Stats::MAX],last[Stats::MAX];
80         unsigned int perSec[Stats::MAX];
81         unsigned int    lastUpdate;
82 };
83
84 extern Stats stats;
85
86
87 #endif
88