Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gpuperformance.h
Go to the documentation of this file.
1 
18 #ifndef ION_ANALYTICS_GPUPERFORMANCE_H_
19 #define ION_ANALYTICS_GPUPERFORMANCE_H_
20 
21 #if !ION_PRODUCTION
22 
23 #include <functional>
24 #include <ostream> // NOLINT
25 #include <utility>
26 #include <vector>
27 
28 #include "base/integral_types.h"
30 #include "ion/external/gtest/gunit_prod.h" // For FRIEND_TEST().
32 #include "ion/gfx/node.h"
33 #include "ion/gfx/renderer.h"
34 
35 namespace ion {
36 namespace analytics {
37 
74 class ION_API GpuPerformanceTester {
75  public:
79  static const double kInvalidValue;
80 
96 
97  enum Enables {
98  kNoEnables = 0x00,
99  kConstants = 0x01,
100  kBaseline = 0x02,
101  kNoDraw = 0x04,
102  kMinimumViewport = 0x08,
103  kResource = 0x10,
104  kGpuMemory = 0x20,
105  kGlTrace = 0x40,
106  kAllEnables = 0x7F
107  };
108 
109  struct Measurement {
110  Measurement(double mean_value, double standard_deviation,
111  double reciprocal_mean, double reciprocal_deviation,
112  double minimum_value, double maximum_value)
113  : mean(mean_value),
114  deviation(standard_deviation),
115  inverse_mean(reciprocal_mean),
116  inverse_deviation(reciprocal_deviation),
117  minimum(minimum_value), maximum(maximum_value) {}
118  double mean;
119  double deviation;
120  double inverse_mean;
122  double minimum;
123  double maximum;
124  };
125 
129 
157  kTotalGpuMemory
158  };
159 
161 
178  kFillPercent
179  };
180 
182  GpuPerformanceTester(uint32 width, uint32 height);
183  virtual ~GpuPerformanceTester();
184 
190  void SetEnables(Enables enables);
191  Enables GetEnables() const { return enables_; }
193  bool AreModesEnabled(Enables enables) const {
194  return (enables_ & enables) == enables;
195  }
196 
198  virtual const Benchmark RunAllMeasurements(
199  const gfx::NodePtr& scene,
200  const gfx::GraphicsManagerPtr& graphics_manager,
201  const gfx::RendererPtr& renderer);
202 
205  virtual void AccumulateMeasurements(
206  const gfx::NodePtr& scene,
207  const gfx::GraphicsManagerPtr& graphics_manager,
208  const gfx::RendererPtr& renderer);
209 
212  virtual const Benchmark GetResults();
213 
215  int GetTrialCount() const { return number_of_trials_; }
216  void SetTrialCount(int number_of_trials) {
217  number_of_trials_ = number_of_trials;
218  }
219 
220  protected:
223  virtual Measurement MeasurePerformance(
224  const gfx::NodePtr& scene,
225  const gfx::GraphicsManagerPtr& graphics_manager,
226  const gfx::RendererPtr& renderer);
227 
229  virtual Measurement MeasureBaseline(
230  const gfx::NodePtr& scene,
231  const gfx::GraphicsManagerPtr& graphics_manager,
232  const gfx::RendererPtr& renderer);
233 
237  virtual Measurement MeasureMinViewportSpeed(
238  const gfx::NodePtr& scene,
239  const gfx::GraphicsManagerPtr& graphics_manager,
240  const gfx::RendererPtr& renderer);
241 
247  virtual Measurement MeasureStateChanges(
248  const gfx::NodePtr& scene,
249  const gfx::GraphicsManagerPtr& graphics_manager,
250  const gfx::RendererPtr& renderer);
251 
255  virtual Measurement MeasureResourceCreation(
256  const gfx::NodePtr& scene,
257  const gfx::GraphicsManagerPtr& graphics_manager);
258 
261  static gfx::NodePtr InstanceCopy(const gfx::NodePtr& scene);
262 
264  uint32 width_;
265  uint32 height_;
266 
269 
272 
285  size_t fbo_memory_;
294 
296  FRIEND_TEST(GPUPerformanceTest, InstanceCopy);
297 };
298 
302  return static_cast<GpuPerformanceTester::Enables>(
303  static_cast<int>(left) | static_cast<int>(right));
304 }
305 
308  if ((enables & kResource) && (enables & kGpuMemory)) {
309  enables = static_cast<GpuPerformanceTester::Enables>(
310  static_cast<int>(enables) & ~static_cast<int>(kResource));
311  LOG(WARNING) <<
312  "GpuPerformanceTester: kResource and kGpuMemory are incompatible" <<
313  std::endl << "Disabling kResource" << std::endl;
314  }
315  enables_ = enables;
316 }
317 
318 } // namespace analytics
319 } // namespace ion
320 
321 #endif // ION_PRODUCTION
322 
323 #endif // ION_ANALYTICS_GPUPERFORMANCE_H_
Benchmark::AccumulatedVariable min_viewport_
Benchmark::AccumulatedVariable baseline_
ConstantIndices
Named indices for each entries in the Benchmark returned by RunAllMeasurements() and GetResults()...
static const double kInvalidValue
This is used for values that with no meaning & should not be printed.
Benchmark::AccumulatedVariable min_viewport_inverse_
bool AreModesEnabled(Enables enables) const
Returns true if all of the specified modes are currently enabled.
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
Definition: logging.h:216
Benchmark benchmark_
The finalized benchmark data.
void SetEnables(Enables enables)
Enable only modes indicated by enables bitmask (effectively clearing the bitmask and setting the indi...
GPUPerformanceTester measures basic GPU rendering characteristics.
int num_nodes_
Benchmark data in progress.
Enables
Enable/disable five modes of GPU performance measurement:
int GetTrialCount() const
Returns/sets the number of trials used to measure performance.
Benchmark::AccumulatedVariable baseline_inverse_
void SetTrialCount(int number_of_trials)
Enables enables_
Enable and disable measurement phases.
int width
Benchmark::AccumulatedVariable no_draw_calls_
GpuPerformanceTester::Enables operator|(GpuPerformanceTester::Enables left, GpuPerformanceTester::Enables right)
The Benchmark class provides types and utilities to make it easier to create performance benchmarks...
Definition: benchmark.h:34
Benchmark::AccumulatedVariable resource_
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Definition: sharedptr.h:60
Measurement(double mean_value, double standard_deviation, double reciprocal_mean, double reciprocal_deviation, double minimum_value, double maximum_value)
This struct represents accumulated values for a variable.
Definition: benchmark.h:84