All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PerformanceTestRunner.h
1 // Copyright (c) 2014 eeGeo. All rights reserved.
2 
3 #pragma once
4 
5 #include "VectorMath.h"
6 #include "CatmullRomSpline.h"
7 #include "ICallback.h"
8 #include "Types.h"
9 #include "DebugDecl.h"
10 #include "CallbackCollection.h"
11 #include "CameraSplinePlaybackController.h"
12 #include "IDebugStats.h"
13 #include <vector>
14 #include <map>
15 #include <string>
16 #include <utility>
17 #include "CoordinateConversion.h"
18 
19 namespace Eegeo
20 {
21  namespace Debug
22  {
23  namespace Profile
24  {
25  namespace PerformanceTestState
26  {
27  enum Values
28  {
29  Started,
30  Ended
31  };
32  }
33 
34  struct SplineData
35  {
36  std::vector<Eegeo::dv3> cameraPositionsEcef;
37  std::vector<Eegeo::dv3> targetPositionsEcef;
38  Geometry::TimeParameterizationMethod::Values interpolationMethod;
39  float playbackSpeed;
40 
41  void AddPoint(const Eegeo::dv3& cameraPositionEcef, const Eegeo::dv3& targetPositionEcef)
42  {
43  cameraPositionsEcef.push_back(cameraPositionEcef);
44  targetPositionsEcef.push_back(targetPositionEcef);
45  }
46 
47  void AddPoint(const Eegeo::Space::LatLongAltitude& cameraPosition, const Eegeo::Space::LatLongAltitude& targetPosition)
48  {
49  AddPoint(cameraPosition.ToECEF(), targetPosition.ToECEF());
50  }
51  };
52 
54  {
55  std::string ToString() const;
56 
57  float AverageFramesPerSecond;
58  float MaxFrameTimeMS;
59  size_t MemoryUsedBytes;
60  size_t PrivateDirtyByteCount;
61  size_t HeapByteCount;
62  size_t TextureByteCount;
63  size_t VertexIndexBufferByteCount;
64 
65  typedef std::pair<std::string, StreamStat> TNamedStreamStat;
66 
67  std::vector<TNamedStreamStat > StreamNameToStatPairs;
68  };
69 
71  {
72  struct TestState
73  {
74  TestState();
75  void Stop();
76  void Start(const std::string& splineName, const int loopCount);
77  void SingleSplineCompleted();
78  bool IsTestCompleted() const;
79 
80  bool IsActive() const { return m_isActive; }
81  const std::string& SplineName() const { return m_splineName; }
82 
83  private:
84  bool m_isActive;
85  int m_splineRunsCompleted;
86  std::string m_splineName;
87  int m_loopCount;
88  };
89 
90  public:
91  typedef std::map<std::string, SplineData> TNameSplineData;
92 
95  Debug::IDebugStats& debugStats);
97 
98  bool IsTestInProgress() const { return m_state.IsActive(); }
99 
100  void RegisterCameraSpline(const std::string& name, const SplineData& data);
101 
102  void RegisterPerformanceTestCompletedCallback(Helpers::ICallback1<const PerformanceTestReport&>& callback);
103  void UnregisterPerformanceTestCompletedCallback(Helpers::ICallback1<const PerformanceTestReport&>& callback);
104 
105  void RegisterPerformanceTestStateChangedCallback(Helpers::ICallback1<const PerformanceTestState::Values&>& callback);
106  void UnregisterPerformanceTestStateChangedCallback(Helpers::ICallback1<const PerformanceTestState::Values&>& callback);
107 
108  bool TryBeginSplineCameraPathPerformanceTest(const std::string& splineName, const int loopCount);
109 
110  private:
111  void HandlePlaybackStateChanged(const Camera::SplinePlayback::SplinePlaybackState& state);
112 
113  SplinePlayback::DebugCameraSplinePlaybackService& m_debugSplinePlaybackService;
114  Debug::IDebugStats& m_debugStats;
115  std::map<std::string, SplineData> m_nameToSplineData;
116 
118  Helpers::CallbackCollection1<const PerformanceTestState::Values&> m_performanceTestStatedChangedCallbacks;
119  Helpers::CallbackCollection1<const PerformanceTestReport&> m_performanceTestCompletedCallbacks;
120  TestState m_state;
121  };
122  }
123  }
124 }
125 
126