Started implementing PerformanceHelper class

This commit is contained in:
Alexander Bock
2016-06-06 03:53:42 +02:00
parent 1430f6b9c2
commit ff0b916b90
4 changed files with 46 additions and 0 deletions

View File

@@ -25,9 +25,26 @@
#ifndef __PERFORMANCEHELPER_H__
#define __PERFORMANCEHELPER_H__
#include <chrono>
#include <string>
namespace openspace {
namespace performance {
class PerformanceManager;
class PerformanceHelper {
public:
PerformanceHelper(std::string identifier, performance::PerformanceManager* manager);
~PerformanceHelper();
private:
std::string _identifier;
performance::PerformanceManager* _manager;
std::chrono::high_resolution_clock::time_point _startTime;
};
} // namespace performance
} // namespace openspace

View File

@@ -25,6 +25,7 @@
#ifndef __PERFORMANCEMANAGER_H__
#define __PERFORMANCEMANAGER_H__
#include <chrono>
#include <vector>
namespace ghoul {
@@ -45,6 +46,8 @@ public:
~PerformanceManager();
bool isMeasuringPerformance() const;
void storeIndividualPerformanceMeasurement(std::string identifier, long long us);
void storeScenePerformanceMeasurements(const std::vector<SceneGraphNode*>& sceneNodes);
private:

View File

@@ -24,9 +24,31 @@
#include <openspace/performance/performancehelper.h>
#include <openspace/performance/performancemanager.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace openspace {
namespace performance {
PerformanceHelper::PerformanceHelper(std::string identifier,
performance::PerformanceManager* manager)
: _identifier(std::move(identifier))
, _manager(manager)
{
glFinish();
_startTime = std::chrono::high_resolution_clock::now();
}
PerformanceHelper::~PerformanceHelper() {
auto endTime = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
endTime - _startTime).count();
_manager->storeIndividualPerformanceMeasurement(std::move(_identifier), duration);
}
} // namespace performance
} // namespace openspace

View File

@@ -54,6 +54,10 @@ bool PerformanceManager::isMeasuringPerformance() const {
return _doPerformanceMeasurements;
}
void PerformanceManager::storeIndividualPerformanceMeasurement(std::string identifier, long long us) {
}
void PerformanceManager::storeScenePerformanceMeasurements(
const std::vector<SceneGraphNode*>& sceneNodes)
{