Skip to content

Commit

Permalink
[Utils] Instrumented utility features for profiling purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
Razakhel committed Mar 21, 2024
1 parent 52a47aa commit ed8ee57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/RaZ/Utils/FileUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "RaZ/Utils/FilePath.hpp"
#include "RaZ/Utils/FileUtils.hpp"

#include "tracy/Tracy.hpp"

#include <fstream>

namespace Raz::FileUtils {
Expand All @@ -9,6 +11,8 @@ namespace {

template <typename T>
T readFile(const FilePath& filePath) {
ZoneScopedN("[FileUtils]::readFile");

std::ifstream file(filePath, std::ios::binary | std::ios::ate);

if (!file)
Expand Down Expand Up @@ -39,10 +43,12 @@ bool isReadable(const FilePath& filePath) {
}

std::vector<unsigned char> readFileToArray(const FilePath& filePath) {
ZoneScopedN("FileUtils::readFileToArray");
return readFile<std::vector<unsigned char>>(filePath);
}

std::string readFileToString(const FilePath& filePath) {
ZoneScopedN("FileUtils::readFileToString");
return readFile<std::string>(filePath);
}

Expand Down
6 changes: 6 additions & 0 deletions src/RaZ/Utils/ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
#include "RaZ/Utils/Threading.hpp"
#include "RaZ/Utils/ThreadPool.hpp"

#include "tracy/Tracy.hpp"

namespace Raz {

ThreadPool::ThreadPool() : ThreadPool(Threading::getSystemThreadCount()) {}

ThreadPool::ThreadPool(unsigned int threadCount) {
ZoneScopedN("ThreadPool::ThreadPool");

Logger::debug("[ThreadPool] Initializing (with " + std::to_string(threadCount) + " thread(s))...");

m_threads.reserve(threadCount);
Expand Down Expand Up @@ -45,6 +49,8 @@ void ThreadPool::addAction(std::function<void()> action) {
}

ThreadPool::~ThreadPool() {
ZoneScopedN("ThreadPool::~ThreadPool");

Logger::debug("[ThreadPool] Destroying...");

{
Expand Down

0 comments on commit ed8ee57

Please sign in to comment.