32 lines
845 B
C++
32 lines
845 B
C++
/*
|
|
* 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 OpenVulkano
|
|
{
|
|
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);
|
|
}
|
|
};
|
|
}
|