diff options
Diffstat (limited to 'OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs')
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs b/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs new file mode 100644 index 0000000..26ecf01 --- /dev/null +++ b/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Region.Environment.Scenes; | ||
5 | using libsecondlife; | ||
6 | using OpenSim.Framework.Types; | ||
7 | using System.Timers; | ||
8 | using System.Diagnostics; | ||
9 | |||
10 | namespace SimpleApp | ||
11 | { | ||
12 | public class CpuCounterObject : SceneObject | ||
13 | { | ||
14 | private PerformanceCounter m_counter; | ||
15 | |||
16 | public CpuCounterObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) | ||
17 | : base(world, eventManager, ownerID, localID, pos, shape ) | ||
18 | { | ||
19 | String objectName = "Processor"; | ||
20 | String counterName = "% Processor Time"; | ||
21 | String instanceName = "_Total"; | ||
22 | |||
23 | m_counter = new PerformanceCounter(objectName, counterName, instanceName); | ||
24 | } | ||
25 | |||
26 | public override void Update( ) | ||
27 | { | ||
28 | float cpu = m_counter.NextValue() / 40f; | ||
29 | LLVector3 size = new LLVector3(cpu, cpu, cpu); | ||
30 | rootPrimitive.ResizeGoup( size ); | ||
31 | |||
32 | base.Update(); | ||
33 | } | ||
34 | } | ||
35 | } | ||