Add simple block profiler
This commit is contained in:
31
openVulkanoCpp/Base/BlockProfiler.hpp
Normal file
31
openVulkanoCpp/Base/BlockProfiler.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Logger.hpp"
|
||||
|
||||
namespace openVulkanoCpp
|
||||
{
|
||||
class BlockProfiler final
|
||||
{
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> start;
|
||||
const std::string name;
|
||||
|
||||
public:
|
||||
BlockProfiler(const std::string& name) : name(name)
|
||||
{
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
~BlockProfiler()
|
||||
{
|
||||
const std::chrono::time_point<std::chrono::high_resolution_clock> done = std::chrono::high_resolution_clock::now();
|
||||
const auto time = std::chrono::duration_cast<std::chrono::microseconds>(done - start);
|
||||
Logger::PERF->info("Block {} took {:.3f} ms", name, time.count() / 1000.0);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user