VirtualBox

source: vbox/trunk/src/VBox/Main/include/Performance.h@ 40084

Last change on this file since 40084 was 40084, checked in by vboxsync, 13 years ago

Main/Metrics: Guests now push collected metrics to VBoxSVC instead of being polled (#6029)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.0 KB
Line 
1/* $Id: Performance.h 40084 2012-02-12 14:01:47Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Performance Classes declaration.
4 */
5
6/*
7 * Copyright (C) 2008 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#ifndef ___performance_h
18#define ___performance_h
19
20#include <VBox/com/defs.h>
21#include <VBox/com/ptr.h>
22#include <VBox/com/string.h>
23#include <VBox/com/VirtualBox.h>
24
25#include <iprt/types.h>
26#include <iprt/err.h>
27
28#include <algorithm>
29#include <functional> /* For std::fun_ptr in testcase */
30#include <list>
31#include <vector>
32
33/* Forward decl. */
34class Machine;
35
36namespace pm
37{
38 /* CPU load is measured in 1/1000 of per cent. */
39 const uint64_t PM_CPU_LOAD_MULTIPLIER = UINT64_C(100000);
40
41 /* Sub Metrics **********************************************************/
42 class CircularBuffer
43 {
44 public:
45 CircularBuffer() : mData(0), mLength(0), mEnd(0), mWrapped(false) {};
46 ~CircularBuffer() { if (mData) RTMemFree(mData); };
47 void init(ULONG length);
48 ULONG length();
49 ULONG getSequenceNumber() { return mSequenceNumber; }
50 void put(ULONG value);
51 void copyTo(ULONG *data);
52 private:
53 ULONG *mData;
54 ULONG mLength;
55 ULONG mEnd;
56 ULONG mSequenceNumber;
57 bool mWrapped;
58 };
59
60 class SubMetric : public CircularBuffer
61 {
62 public:
63 SubMetric(const char *name, const char *description)
64 : mName(name), mDescription(description) {};
65 void query(ULONG *data);
66 const char *getName() { return mName; };
67 const char *getDescription() { return mDescription; };
68 private:
69 const char *mName;
70 const char *mDescription;
71 };
72
73
74 enum {
75 COLLECT_NONE = 0x0,
76 COLLECT_CPU_LOAD = 0x1,
77 COLLECT_RAM_USAGE = 0x2,
78 COLLECT_GUEST_STATS = 0x4
79 };
80 typedef int HintFlags;
81 typedef std::pair<RTPROCESS, HintFlags> ProcessFlagsPair;
82
83 class CollectorHints
84 {
85 public:
86 typedef std::list<ProcessFlagsPair> ProcessList;
87
88 CollectorHints() : mHostFlags(COLLECT_NONE) {}
89 void collectHostCpuLoad()
90 { mHostFlags |= COLLECT_CPU_LOAD; }
91 void collectHostRamUsage()
92 { mHostFlags |= COLLECT_RAM_USAGE; }
93 void collectHostRamVmm()
94 { mHostFlags |= COLLECT_GUEST_STATS; }
95 void collectProcessCpuLoad(RTPROCESS process)
96 { findProcess(process).second |= COLLECT_CPU_LOAD; }
97 void collectProcessRamUsage(RTPROCESS process)
98 { findProcess(process).second |= COLLECT_RAM_USAGE; }
99 void collectGuestStats(RTPROCESS process)
100 { findProcess(process).second |= COLLECT_GUEST_STATS; }
101 bool isHostCpuLoadCollected() const
102 { return (mHostFlags & COLLECT_CPU_LOAD) != 0; }
103 bool isHostRamUsageCollected() const
104 { return (mHostFlags & COLLECT_RAM_USAGE) != 0; }
105 bool isHostRamVmmCollected() const
106 { return (mHostFlags & COLLECT_GUEST_STATS) != 0; }
107 bool isProcessCpuLoadCollected(RTPROCESS process)
108 { return (findProcess(process).second & COLLECT_CPU_LOAD) != 0; }
109 bool isProcessRamUsageCollected(RTPROCESS process)
110 { return (findProcess(process).second & COLLECT_RAM_USAGE) != 0; }
111 bool isGuestStatsCollected(RTPROCESS process)
112 { return (findProcess(process).second & COLLECT_GUEST_STATS) != 0; }
113 void getProcesses(std::vector<RTPROCESS>& processes) const
114 {
115 processes.clear();
116 processes.reserve(mProcesses.size());
117 for (ProcessList::const_iterator it = mProcesses.begin(); it != mProcesses.end(); it++)
118 processes.push_back(it->first);
119 }
120 const ProcessList& getProcessFlags() const
121 {
122 return mProcesses;
123 }
124 private:
125 HintFlags mHostFlags;
126 ProcessList mProcesses;
127
128 ProcessFlagsPair& findProcess(RTPROCESS process)
129 {
130 ProcessList::iterator it;
131 for (it = mProcesses.begin(); it != mProcesses.end(); it++)
132 if (it->first == process)
133 return *it;
134
135 /* Not found -- add new */
136 mProcesses.push_back(ProcessFlagsPair(process, COLLECT_NONE));
137 return mProcesses.back();
138 }
139 };
140
141 /* Guest Collector Classes *********************************/
142 /*
143 * WARNING! The bits in the following masks must correspond to parameters
144 * of CollectorGuest::updateStats().
145 */
146 typedef enum
147 {
148 GUESTSTATMASK_NONE = 0x00000000,
149 GUESTSTATMASK_CPUUSER = 0x00000001,
150 GUESTSTATMASK_CPUKERNEL = 0x00000002,
151 GUESTSTATMASK_CPUIDLE = 0x00000004,
152 GUESTSTATMASK_MEMTOTAL = 0x00000008,
153 GUESTSTATMASK_MEMFREE = 0x00000010,
154 GUESTSTATMASK_MEMBALLOON = 0x00000020,
155 GUESTSTATMASK_MEMSHARED = 0x00000040,
156 GUESTSTATMASK_MEMCACHE = 0x00000080,
157 GUESTSTATMASK_PAGETOTAL = 0x00000100,
158 GUESTSTATMASK_ALLOCVMM = 0x00000200,
159 GUESTSTATMASK_FREEVMM = 0x00000400,
160 GUESTSTATMASK_BALOONVMM = 0x00000800,
161 GUESTSTATMASK_SHAREDVMM = 0x00001000
162 } GUESTSTATMASK;
163
164 const ULONG GUESTSTATS_CPULOAD =
165 GUESTSTATMASK_CPUUSER|GUESTSTATMASK_CPUKERNEL|GUESTSTATMASK_CPUIDLE;
166 const ULONG GUESTSTATS_RAMUSAGE =
167 GUESTSTATMASK_MEMTOTAL|GUESTSTATMASK_MEMFREE|GUESTSTATMASK_MEMBALLOON|
168 GUESTSTATMASK_MEMSHARED|GUESTSTATMASK_MEMCACHE|
169 GUESTSTATMASK_PAGETOTAL;
170 const ULONG GUESTSTATS_VMMRAM =
171 GUESTSTATMASK_ALLOCVMM|GUESTSTATMASK_FREEVMM|
172 GUESTSTATMASK_BALOONVMM|GUESTSTATMASK_SHAREDVMM;
173
174 class CollectorGuest
175 {
176 public:
177 CollectorGuest(Machine *machine, RTPROCESS process);
178 ~CollectorGuest();
179
180 bool isUnregistered() { return mUnregistered; };
181 bool isEnabled() { return mEnabled; };
182 bool isValid(ULONG mask){ return (mValid & mask) == mask; };
183 void invalidateStats() { mValid = 0; };
184 void unregister() { mUnregistered = true; };
185 void updateStats(ULONG aValidStats, ULONG aCpuUser,
186 ULONG aCpuKernel, ULONG aCpuIdle,
187 ULONG aMemTotal, ULONG aMemFree,
188 ULONG aMemBalloon, ULONG aMemShared,
189 ULONG aMemCache, ULONG aPageTotal,
190 ULONG aAllocVMM, ULONG aFreeVMM,
191 ULONG aBalloonedVMM, ULONG aSharedVMM);
192 int enable();
193 int disable();
194 int enableVMMStats(bool mCollectVMMStats);
195
196 RTPROCESS getProcess() { return mProcess; };
197 ULONG getCpuUser() { return mCpuUser; };
198 ULONG getCpuKernel() { return mCpuKernel; };
199 ULONG getCpuIdle() { return mCpuIdle; };
200 ULONG getMemTotal() { return mMemTotal; };
201 ULONG getMemFree() { return mMemFree; };
202 ULONG getMemBalloon() { return mMemBalloon; };
203 ULONG getMemShared() { return mMemShared; };
204 ULONG getMemCache() { return mMemCache; };
205 ULONG getPageTotal() { return mPageTotal; };
206 ULONG getAllocVMM() { return mAllocVMM; };
207 ULONG getFreeVMM() { return mFreeVMM; };
208 ULONG getBalloonedVMM() { return mBalloonedVMM; };
209 ULONG getSharedVMM() { return mSharedVMM; };
210
211 private:
212 bool mUnregistered;
213 bool mEnabled;
214 ULONG mValid;
215 Machine *mMachine;
216 RTPROCESS mProcess;
217 ComPtr<IConsole> mConsole;
218 ComPtr<IGuest> mGuest;
219 ULONG mCpuUser;
220 ULONG mCpuKernel;
221 ULONG mCpuIdle;
222 ULONG mMemTotal;
223 ULONG mMemFree;
224 ULONG mMemBalloon;
225 ULONG mMemShared;
226 ULONG mMemCache;
227 ULONG mPageTotal;
228 ULONG mAllocVMM;
229 ULONG mFreeVMM;
230 ULONG mBalloonedVMM;
231 ULONG mSharedVMM;
232 };
233
234 typedef std::list<CollectorGuest*> CollectorGuestList;
235 class CollectorGuestManager
236 {
237 public:
238 CollectorGuestManager() : mVMMStatsProvider(NULL) {};
239 ~CollectorGuestManager() { Assert(mGuests.size() == 0); };
240 void registerGuest(CollectorGuest* pGuest);
241 void unregisterGuest(CollectorGuest* pGuest);
242 CollectorGuest *getVMMStatsProvider() { return mVMMStatsProvider; };
243 void preCollect(CollectorHints& hints, uint64_t iTick);
244 void destroyUnregistered();
245 private:
246 CollectorGuestList mGuests;
247 CollectorGuest *mVMMStatsProvider;
248 };
249
250 /* Collector Hardware Abstraction Layer *********************************/
251 class CollectorHAL
252 {
253 public:
254 CollectorHAL() {};
255 virtual ~CollectorHAL() { };
256 virtual int preCollect(const CollectorHints& /* hints */, uint64_t /* iTick */) { return VINF_SUCCESS; }
257 /** Returns averaged CPU usage in 1/1000th per cent across all host's CPUs. */
258 virtual int getHostCpuLoad(ULONG *user, ULONG *kernel, ULONG *idle);
259 /** Returns the average frequency in MHz across all host's CPUs. */
260 virtual int getHostCpuMHz(ULONG *mhz);
261 /** Returns the amount of physical memory in kilobytes. */
262 virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available);
263 /** Returns CPU usage in 1/1000th per cent by a particular process. */
264 virtual int getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel);
265 /** Returns the amount of memory used by a process in kilobytes. */
266 virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);
267
268 /** Returns CPU usage counters in platform-specific units. */
269 virtual int getRawHostCpuLoad(uint64_t *user, uint64_t *kernel, uint64_t *idle);
270 /** Returns process' CPU usage counter in platform-specific units. */
271 virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total);
272 };
273
274 extern CollectorHAL *createHAL();
275
276 /* Base Metrics *********************************************************/
277 class BaseMetric
278 {
279 public:
280 BaseMetric(CollectorHAL *hal, const char *name, ComPtr<IUnknown> object)
281 : mPeriod(0), mLength(0), mHAL(hal), mName(name), mObject(object),
282 mLastSampleTaken(0), mEnabled(false), mUnregistered(false) {};
283 virtual ~BaseMetric() {};
284
285 virtual void init(ULONG period, ULONG length) = 0;
286 virtual void preCollect(CollectorHints& hints, uint64_t iTick) = 0;
287 virtual void collect() = 0;
288 virtual const char *getUnit() = 0;
289 virtual ULONG getMinValue() = 0;
290 virtual ULONG getMaxValue() = 0;
291 virtual ULONG getScale() = 0;
292
293 bool collectorBeat(uint64_t nowAt);
294
295 void enable() { mEnabled = true; };
296 void disable() { mEnabled = false; };
297 void unregister() { mUnregistered = true; };
298
299 bool isUnregistered() { return mUnregistered; };
300 bool isEnabled() { return mEnabled; };
301 ULONG getPeriod() { return mPeriod; };
302 ULONG getLength() { return mLength; };
303 const char *getName() { return mName; };
304 ComPtr<IUnknown> getObject() { return mObject; };
305 bool associatedWith(ComPtr<IUnknown> object) { return mObject == object; };
306
307 protected:
308 ULONG mPeriod;
309 ULONG mLength;
310 CollectorHAL *mHAL;
311 const char *mName;
312 ComPtr<IUnknown> mObject;
313 uint64_t mLastSampleTaken;
314 bool mEnabled;
315 bool mUnregistered;
316 };
317
318 class BaseGuestMetric : public BaseMetric
319 {
320 public:
321 BaseGuestMetric(CollectorGuest *cguest, const char *name, ComPtr<IUnknown> object)
322 : BaseMetric(NULL, name, object), mCGuest(cguest) {};
323 protected:
324 CollectorGuest *mCGuest;
325 };
326
327 class HostCpuLoad : public BaseMetric
328 {
329 public:
330 HostCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
331 : BaseMetric(hal, "CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {};
332 ~HostCpuLoad() { delete mUser; delete mKernel; delete mIdle; };
333
334 void init(ULONG period, ULONG length);
335
336 void collect();
337 const char *getUnit() { return "%"; };
338 ULONG getMinValue() { return 0; };
339 ULONG getMaxValue() { return PM_CPU_LOAD_MULTIPLIER; };
340 ULONG getScale() { return PM_CPU_LOAD_MULTIPLIER / 100; }
341
342 protected:
343 SubMetric *mUser;
344 SubMetric *mKernel;
345 SubMetric *mIdle;
346 };
347
348 class HostCpuLoadRaw : public HostCpuLoad
349 {
350 public:
351 HostCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
352 : HostCpuLoad(hal, object, user, kernel, idle), mUserPrev(0), mKernelPrev(0), mIdlePrev(0) {};
353
354 void preCollect(CollectorHints& hints, uint64_t iTick);
355 void collect();
356 private:
357 uint64_t mUserPrev;
358 uint64_t mKernelPrev;
359 uint64_t mIdlePrev;
360 };
361
362 class HostCpuMhz : public BaseMetric
363 {
364 public:
365 HostCpuMhz(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *mhz)
366 : BaseMetric(hal, "CPU/MHz", object), mMHz(mhz) {};
367 ~HostCpuMhz() { delete mMHz; };
368
369 void init(ULONG period, ULONG length);
370 void preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) {}
371 void collect();
372 const char *getUnit() { return "MHz"; };
373 ULONG getMinValue() { return 0; };
374 ULONG getMaxValue() { return INT32_MAX; };
375 ULONG getScale() { return 1; }
376 private:
377 SubMetric *mMHz;
378 };
379
380 class HostRamUsage : public BaseMetric
381 {
382 public:
383 HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available)
384 : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mUsed(used), mAvailable(available) {};
385 ~HostRamUsage() { delete mTotal; delete mUsed; delete mAvailable; };
386
387 void init(ULONG period, ULONG length);
388 void preCollect(CollectorHints& hints, uint64_t iTick);
389 void collect();
390 const char *getUnit() { return "kB"; };
391 ULONG getMinValue() { return 0; };
392 ULONG getMaxValue() { return INT32_MAX; };
393 ULONG getScale() { return 1; }
394 private:
395 SubMetric *mTotal;
396 SubMetric *mUsed;
397 SubMetric *mAvailable;
398 };
399
400 class HostRamVmm : public BaseMetric
401 {
402 public:
403 HostRamVmm(CollectorGuestManager *gm, ComPtr<IUnknown> object, SubMetric *allocVMM, SubMetric *freeVMM, SubMetric *balloonVMM, SubMetric *sharedVMM)
404 : BaseMetric(NULL, "RAM/VMM", object), mCollectorGuestManager(gm),
405 mAllocVMM(allocVMM), mFreeVMM(freeVMM), mBalloonVMM(balloonVMM), mSharedVMM(sharedVMM),
406 mAllocCurrent(0), mFreeCurrent(0), mBalloonedCurrent(0), mSharedCurrent(0) {};
407 ~HostRamVmm() { delete mAllocVMM; delete mFreeVMM; delete mBalloonVMM; delete mSharedVMM; };
408
409 void init(ULONG period, ULONG length);
410 void preCollect(CollectorHints& hints, uint64_t iTick);
411 void collect();
412 const char *getUnit() { return "kB"; };
413 ULONG getMinValue() { return 0; };
414 ULONG getMaxValue() { return INT32_MAX; };
415 ULONG getScale() { return 1; }
416
417 private:
418 CollectorGuestManager *mCollectorGuestManager;
419 SubMetric *mAllocVMM;
420 SubMetric *mFreeVMM;
421 SubMetric *mBalloonVMM;
422 SubMetric *mSharedVMM;
423 ULONG mAllocCurrent;
424 ULONG mFreeCurrent;
425 ULONG mBalloonedCurrent;
426 ULONG mSharedCurrent;
427 };
428
429 class MachineCpuLoad : public BaseMetric
430 {
431 public:
432 MachineCpuLoad(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
433 : BaseMetric(hal, "CPU/Load", object), mProcess(process), mUser(user), mKernel(kernel) {};
434 ~MachineCpuLoad() { delete mUser; delete mKernel; };
435
436 void init(ULONG period, ULONG length);
437 void collect();
438 const char *getUnit() { return "%"; };
439 ULONG getMinValue() { return 0; };
440 ULONG getMaxValue() { return PM_CPU_LOAD_MULTIPLIER; };
441 ULONG getScale() { return PM_CPU_LOAD_MULTIPLIER / 100; }
442 protected:
443 RTPROCESS mProcess;
444 SubMetric *mUser;
445 SubMetric *mKernel;
446 };
447
448 class MachineCpuLoadRaw : public MachineCpuLoad
449 {
450 public:
451 MachineCpuLoadRaw(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *user, SubMetric *kernel)
452 : MachineCpuLoad(hal, object, process, user, kernel), mHostTotalPrev(0), mProcessUserPrev(0), mProcessKernelPrev(0) {};
453
454 void preCollect(CollectorHints& hints, uint64_t iTick);
455 void collect();
456 private:
457 uint64_t mHostTotalPrev;
458 uint64_t mProcessUserPrev;
459 uint64_t mProcessKernelPrev;
460 };
461
462 class MachineRamUsage : public BaseMetric
463 {
464 public:
465 MachineRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, RTPROCESS process, SubMetric *used)
466 : BaseMetric(hal, "RAM/Usage", object), mProcess(process), mUsed(used) {};
467 ~MachineRamUsage() { delete mUsed; };
468
469 void init(ULONG period, ULONG length);
470 void preCollect(CollectorHints& hints, uint64_t iTick);
471 void collect();
472 const char *getUnit() { return "kB"; };
473 ULONG getMinValue() { return 0; };
474 ULONG getMaxValue() { return INT32_MAX; };
475 ULONG getScale() { return 1; }
476 private:
477 RTPROCESS mProcess;
478 SubMetric *mUsed;
479 };
480
481
482 class GuestCpuLoad : public BaseGuestMetric
483 {
484 public:
485 GuestCpuLoad(CollectorGuest *cguest, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)
486 : BaseGuestMetric(cguest, "Guest/CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {};
487 ~GuestCpuLoad() { delete mUser; delete mKernel; delete mIdle; };
488
489 void init(ULONG period, ULONG length);
490 void preCollect(CollectorHints& hints, uint64_t iTick);
491 void collect();
492 const char *getUnit() { return "%"; };
493 ULONG getMinValue() { return 0; };
494 ULONG getMaxValue() { return PM_CPU_LOAD_MULTIPLIER; };
495 ULONG getScale() { return PM_CPU_LOAD_MULTIPLIER / 100; }
496 protected:
497 SubMetric *mUser;
498 SubMetric *mKernel;
499 SubMetric *mIdle;
500 };
501
502 class GuestRamUsage : public BaseGuestMetric
503 {
504 public:
505 GuestRamUsage(CollectorGuest *cguest, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *shared, SubMetric *cache, SubMetric *pagedtotal)
506 : BaseGuestMetric(cguest, "Guest/RAM/Usage", object), mTotal(total), mFree(free), mBallooned(balloon), mCache(cache), mPagedTotal(pagedtotal), mShared(shared) {};
507 ~GuestRamUsage() { delete mTotal; delete mFree; delete mBallooned; delete mShared; delete mCache; delete mPagedTotal; };
508
509 void init(ULONG period, ULONG length);
510 void preCollect(CollectorHints& hints, uint64_t iTick);
511 void collect();
512 const char *getUnit() { return "kB"; };
513 ULONG getMinValue() { return 0; };
514 ULONG getMaxValue() { return INT32_MAX; };
515 ULONG getScale() { return 1; }
516 private:
517 SubMetric *mTotal, *mFree, *mBallooned, *mCache, *mPagedTotal, *mShared;
518 };
519
520 /* Aggregate Functions **************************************************/
521 class Aggregate
522 {
523 public:
524 virtual ULONG compute(ULONG *data, ULONG length) = 0;
525 virtual const char *getName() = 0;
526 };
527
528 class AggregateAvg : public Aggregate
529 {
530 public:
531 virtual ULONG compute(ULONG *data, ULONG length);
532 virtual const char *getName();
533 };
534
535 class AggregateMin : public Aggregate
536 {
537 public:
538 virtual ULONG compute(ULONG *data, ULONG length);
539 virtual const char *getName();
540 };
541
542 class AggregateMax : public Aggregate
543 {
544 public:
545 virtual ULONG compute(ULONG *data, ULONG length);
546 virtual const char *getName();
547 };
548
549 /* Metric Class *********************************************************/
550 class Metric
551 {
552 public:
553 Metric(BaseMetric *baseMetric, SubMetric *subMetric, Aggregate *aggregate) :
554 mName(subMetric->getName()), mBaseMetric(baseMetric), mSubMetric(subMetric), mAggregate(aggregate)
555 {
556 if (mAggregate)
557 {
558 mName.append(":");
559 mName.append(mAggregate->getName());
560 }
561 }
562
563 ~Metric()
564 {
565 delete mAggregate;
566 }
567 bool associatedWith(ComPtr<IUnknown> object) { return getObject() == object; };
568
569 const char *getName() { return mName.c_str(); };
570 ComPtr<IUnknown> getObject() { return mBaseMetric->getObject(); };
571 const char *getDescription()
572 { return mAggregate ? "" : mSubMetric->getDescription(); };
573 const char *getUnit() { return mBaseMetric->getUnit(); };
574 ULONG getMinValue() { return mBaseMetric->getMinValue(); };
575 ULONG getMaxValue() { return mBaseMetric->getMaxValue(); };
576 ULONG getPeriod() { return mBaseMetric->getPeriod(); };
577 ULONG getLength()
578 { return mAggregate ? 1 : mBaseMetric->getLength(); };
579 ULONG getScale() { return mBaseMetric->getScale(); }
580 void query(ULONG **data, ULONG *count, ULONG *sequenceNumber);
581
582 private:
583 RTCString mName;
584 BaseMetric *mBaseMetric;
585 SubMetric *mSubMetric;
586 Aggregate *mAggregate;
587 };
588
589 /* Filter Class *********************************************************/
590
591 class Filter
592 {
593 public:
594 Filter(ComSafeArrayIn(IN_BSTR, metricNames),
595 ComSafeArrayIn(IUnknown * , objects));
596 static bool patternMatch(const char *pszPat, const char *pszName,
597 bool fSeenColon = false);
598 bool match(const ComPtr<IUnknown> object, const RTCString &name) const;
599 private:
600 void init(ComSafeArrayIn(IN_BSTR, metricNames),
601 ComSafeArrayIn(IUnknown * , objects));
602
603 typedef std::pair<const ComPtr<IUnknown>, const RTCString> FilterElement;
604 typedef std::list<FilterElement> ElementList;
605
606 ElementList mElements;
607
608 void processMetricList(const com::Utf8Str &name, const ComPtr<IUnknown> object);
609 };
610}
611#endif /* ___performance_h */
612/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette