diff options
author | Justin Clarke Casey | 2008-05-14 21:27:54 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-14 21:27:54 +0000 |
commit | 56faeafdae5b4b76593e268bc994a7f663bd5685 (patch) | |
tree | 720efa22432151d2faaab08c61065a0ba02a047f /OpenSim/Framework/Statistics/SimExtraStatsReporter.cs | |
parent | * Fixed attaching objects that are in-world. (diff) | |
download | opensim-SC-56faeafdae5b4b76593e268bc994a7f663bd5685.zip opensim-SC-56faeafdae5b4b76593e268bc994a7f663bd5685.tar.gz opensim-SC-56faeafdae5b4b76593e268bc994a7f663bd5685.tar.bz2 opensim-SC-56faeafdae5b4b76593e268bc994a7f663bd5685.tar.xz |
* Refactor: Renaming non viewer statistics classes from Reporters to Collectors - this seems more intuitive
Diffstat (limited to 'OpenSim/Framework/Statistics/SimExtraStatsReporter.cs')
-rw-r--r-- | OpenSim/Framework/Statistics/SimExtraStatsReporter.cs | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs b/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs deleted file mode 100644 index 567d8dd..0000000 --- a/OpenSim/Framework/Statistics/SimExtraStatsReporter.cs +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using OpenSim.Framework.Statistics.Interfaces; | ||
33 | |||
34 | namespace OpenSim.Framework.Statistics | ||
35 | { | ||
36 | public class SimExtraStatsReporter | ||
37 | { | ||
38 | private long assetsInCache; | ||
39 | private long texturesInCache; | ||
40 | private long assetCacheMemoryUsage; | ||
41 | private long textureCacheMemoryUsage; | ||
42 | |||
43 | public long AssetsInCache { get { return assetsInCache; } } | ||
44 | public long TexturesInCache { get { return texturesInCache; } } | ||
45 | public long AssetCacheMemoryUsage { get { return assetCacheMemoryUsage; } } | ||
46 | public long TextureCacheMemoryUsage { get { return textureCacheMemoryUsage; } } | ||
47 | |||
48 | /// <summary> | ||
49 | /// Retain a dictionary of all packet queues stats reporters | ||
50 | /// </summary> | ||
51 | private IDictionary<LLUUID, PacketQueueStatsReporter> packetQueueStatsReporters | ||
52 | = new Dictionary<LLUUID, PacketQueueStatsReporter>(); | ||
53 | |||
54 | public void AddAsset(AssetBase asset) | ||
55 | { | ||
56 | assetsInCache++; | ||
57 | assetCacheMemoryUsage += asset.Data.Length; | ||
58 | } | ||
59 | |||
60 | public void AddTexture(AssetBase image) | ||
61 | { | ||
62 | // Tedd: I added null check to avoid exception. Don't know if texturesInCache should ++ anyway? | ||
63 | if (image.Data != null) | ||
64 | { | ||
65 | texturesInCache++; | ||
66 | textureCacheMemoryUsage += image.Data.Length; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | /// <summary> | ||
71 | /// Register as a packet queue stats provider | ||
72 | /// </summary> | ||
73 | /// <param name="uuid">An agent LLUUID</param> | ||
74 | /// <param name="provider"></param> | ||
75 | public void RegisterPacketQueueStatsProvider(LLUUID uuid, IPullStatsProvider provider) | ||
76 | { | ||
77 | lock (packetQueueStatsReporters) | ||
78 | { | ||
79 | packetQueueStatsReporters[uuid] = new PacketQueueStatsReporter(provider); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Deregister a packet queue stats provider | ||
85 | /// </summary> | ||
86 | /// <param name="uuid">An agent LLUUID</param> | ||
87 | public void DeregisterPacketQueueStatsProvider(LLUUID uuid) | ||
88 | { | ||
89 | lock (packetQueueStatsReporters) | ||
90 | { | ||
91 | packetQueueStatsReporters.Remove(uuid); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Report back collected statistical information. | ||
97 | /// </summary> | ||
98 | /// <returns></returns> | ||
99 | public string Report() | ||
100 | { | ||
101 | StringBuilder sb = new StringBuilder(Environment.NewLine); | ||
102 | sb.Append("ASSET CACHE STATISTICS"); | ||
103 | sb.Append(Environment.NewLine); | ||
104 | sb.Append( | ||
105 | string.Format( | ||
106 | @"Asset cache contains {0,6} assets using {1,10:0.000}K | ||
107 | Texture cache contains {2,6} textures using {3,10:0.000}K" + Environment.NewLine, | ||
108 | AssetsInCache, AssetCacheMemoryUsage / 1024.0, | ||
109 | TexturesInCache, TextureCacheMemoryUsage / 1024.0)); | ||
110 | |||
111 | sb.Append(Environment.NewLine); | ||
112 | sb.Append("PACKET QUEUE STATISTICS"); | ||
113 | sb.Append(Environment.NewLine); | ||
114 | sb.Append("Agent UUID "); | ||
115 | sb.Append( | ||
116 | string.Format( | ||
117 | " {0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}", | ||
118 | "Send", "In", "Out", "Resend", "Land", "Wind", "Cloud", "Task", "Texture", "Asset")); | ||
119 | sb.Append(Environment.NewLine); | ||
120 | |||
121 | foreach (LLUUID key in packetQueueStatsReporters.Keys) | ||
122 | { | ||
123 | sb.Append(string.Format("{0}: ", key)); | ||
124 | sb.Append(packetQueueStatsReporters[key].Report()); | ||
125 | sb.Append(Environment.NewLine); | ||
126 | } | ||
127 | |||
128 | return sb.ToString(); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Pull packet queue stats from packet queues and report | ||
134 | /// </summary> | ||
135 | public class PacketQueueStatsReporter | ||
136 | { | ||
137 | private IPullStatsProvider m_statsProvider; | ||
138 | |||
139 | public PacketQueueStatsReporter(IPullStatsProvider provider) | ||
140 | { | ||
141 | m_statsProvider = provider; | ||
142 | } | ||
143 | |||
144 | /// <summary> | ||
145 | /// Report back collected statistical information. | ||
146 | /// </summary> | ||
147 | /// <returns></returns> | ||
148 | public string Report() | ||
149 | { | ||
150 | return m_statsProvider.GetStats(); | ||
151 | } | ||
152 | } | ||
153 | } | ||