VirtualBox

source: vbox/trunk/src/VBox/Main/include/PerformanceImpl.h@ 12474

Last change on this file since 12474 was 12400, checked in by vboxsync, 16 years ago

PerfAPI: Improved Win collector. More realistic performance test. No factories.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: PerformanceImpl.h 12400 2008-09-11 10:34:58Z vboxsync $ */
2
3/** @file
4 *
5 * VBox Performance COM Classes declaration.
6 */
7
8/*
9 * Copyright (C) 2008 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_PERFORMANCEIMPL
25#define ____H_PERFORMANCEIMPL
26
27#include "VirtualBoxBase.h"
28
29#include <VBox/com/com.h>
30#include <VBox/com/array.h>
31//#ifdef VBOX_WITH_RESOURCE_USAGE_API
32#include <iprt/timer.h>
33//#endif /* VBOX_WITH_RESOURCE_USAGE_API */
34
35#include <list>
36//#include <set>
37
38#include "Performance.h"
39
40/* Each second we obtain new CPU load stats. */
41#define VBOX_USAGE_SAMPLER_MIN_INTERVAL 1000
42
43class Machine;
44class HostUSBDevice;
45
46class ATL_NO_VTABLE PerformanceMetric :
47 public VirtualBoxBaseNEXT,
48 public VirtualBoxSupportTranslation <PerformanceMetric>,
49 public IPerformanceMetric
50{
51public:
52
53 DECLARE_NOT_AGGREGATABLE (PerformanceMetric)
54
55 DECLARE_PROTECT_FINAL_CONSTRUCT()
56
57 BEGIN_COM_MAP (PerformanceMetric)
58 COM_INTERFACE_ENTRY (IPerformanceMetric)
59 END_COM_MAP()
60
61 NS_DECL_ISUPPORTS
62
63 DECLARE_EMPTY_CTOR_DTOR (PerformanceMetric)
64
65 HRESULT FinalConstruct();
66 void FinalRelease();
67
68 // public initializer/uninitializer for internal purposes only
69 HRESULT init (pm::Metric *aMetric);
70 void uninit();
71
72 // IPerformanceMetric properties
73 STDMETHOD(COMGETTER(MetricName)) (BSTR *aMetricName);
74 STDMETHOD(COMGETTER(Object)) (IUnknown **anObject);
75 STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
76 STDMETHOD(COMGETTER(Period)) (ULONG *aPeriod);
77 STDMETHOD(COMGETTER(Count)) (ULONG *aCount);
78 STDMETHOD(COMGETTER(Unit)) (BSTR *aUnit);
79 STDMETHOD(COMGETTER(MinimumValue)) (LONG *aMinValue);
80 STDMETHOD(COMGETTER(MaximumValue)) (LONG *aMaxValue);
81
82 // IPerformanceMetric methods
83
84 // public methods only for internal purposes
85
86 // public methods for internal purposes only
87 // (ensure there is a caller and a read lock before calling them!)
88
89private:
90
91 struct Data
92 {
93 /* Constructor. */
94 Data() : period(0), count(0), min(0), max(0) { }
95
96 Bstr name;
97 ComPtr<IUnknown> object;
98 Bstr description;
99 ULONG period;
100 ULONG count;
101 Bstr unit;
102 LONG min;
103 LONG max;
104 };
105
106 Data m;
107};
108
109
110class ATL_NO_VTABLE PerformanceCollector :
111 public VirtualBoxBaseNEXT,
112 public VirtualBoxSupportErrorInfoImpl <PerformanceCollector, IPerformanceCollector>,
113 public VirtualBoxSupportTranslation <PerformanceCollector>,
114 public IPerformanceCollector
115{
116public:
117
118 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (PerformanceCollector)
119
120 DECLARE_NOT_AGGREGATABLE (PerformanceCollector)
121
122 DECLARE_PROTECT_FINAL_CONSTRUCT()
123
124 BEGIN_COM_MAP(PerformanceCollector)
125 COM_INTERFACE_ENTRY(ISupportErrorInfo)
126 COM_INTERFACE_ENTRY(IPerformanceCollector)
127 END_COM_MAP()
128
129 NS_DECL_ISUPPORTS
130
131 DECLARE_EMPTY_CTOR_DTOR (PerformanceCollector)
132
133 HRESULT FinalConstruct();
134 void FinalRelease();
135
136 // public initializers/uninitializers only for internal purposes
137 HRESULT init();
138 void uninit();
139
140 // IPerformanceCollector properties
141 STDMETHOD(COMGETTER(MetricNames)) (ComSafeArrayOut (BSTR, metricNames));
142
143 // IPerformanceCollector methods
144 STDMETHOD(GetMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
145 ComSafeArrayIn (IUnknown *, objects),
146 ComSafeArrayOut (IPerformanceMetric *, outMetrics));
147 STDMETHOD(SetupMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
148 ComSafeArrayIn (IUnknown *, objects),
149 ULONG aPeriod, ULONG aCount);
150 STDMETHOD(EnableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
151 ComSafeArrayIn (IUnknown *, objects));
152 STDMETHOD(DisableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
153 ComSafeArrayIn (IUnknown *, objects));
154 STDMETHOD(QueryMetricsData) (ComSafeArrayIn (INPTR BSTR, metricNames),
155 ComSafeArrayIn (IUnknown *, objects),
156 ComSafeArrayOut (BSTR, outMetricNames),
157 ComSafeArrayOut (IUnknown *, outObjects),
158 ComSafeArrayOut (ULONG, outDataIndices),
159 ComSafeArrayOut (ULONG, outDataLengths),
160 ComSafeArrayOut (LONG, outData));
161
162 // public methods only for internal purposes
163
164 void registerBaseMetric (pm::BaseMetric *baseMetric);
165 void registerMetric (pm::Metric *metric);
166 void unregisterBaseMetricsFor (const ComPtr <IUnknown> &object);
167 void unregisterMetricsFor (const ComPtr <IUnknown> &object);
168
169 // public methods for internal purposes only
170 // (ensure there is a caller and a read lock before calling them!)
171
172 pm::CollectorHAL *getHAL() { return m.hal; };
173
174 // for VirtualBoxSupportErrorInfoImpl
175 static const wchar_t *getComponentName() { return L"PerformanceCollector"; }
176
177private:
178
179 static void staticSamplerCallback (RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick);
180 void samplerCallback();
181
182 typedef std::list<pm::Metric*> MetricList;
183 typedef std::list<pm::BaseMetric*> BaseMetricList;
184
185 enum
186 {
187 MAGIC = 0xABBA1972u
188 };
189
190 unsigned int mMagic;
191
192 struct Data
193 {
194 Data() : hal(0) {};
195
196 BaseMetricList baseMetrics;
197 MetricList metrics;
198 RTTIMERLR sampler;
199 pm::CollectorHAL *hal;
200 };
201
202 Data m;
203};
204
205#endif //!____H_PERFORMANCEIMPL
Note: See TracBrowser for help on using the repository browser.

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