mirror of
https://github.com/harfang3d/harfang3d.git
synced 2024-07-01 01:39:42 +00:00
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
// HARFANG(R) Copyright (C) 2021 Emmanuel Julien, NWNC HARFANG. Released under GPL/LGPL/Commercial Licence, see licence.txt for details.
|
|
|
|
#pragma once
|
|
|
|
#include "foundation/time.h"
|
|
|
|
#include <thread>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace hg {
|
|
|
|
struct ProfilerFrame {
|
|
uint32_t frame;
|
|
|
|
struct Section {
|
|
Section() = default;
|
|
Section(const Section &) = default;
|
|
Section(Section &&s) : thread_id(s.thread_id), start(s.start), end(s.end), details(std::move(s.details)) {}
|
|
|
|
std::thread::id thread_id;
|
|
time_ns start{0}, end{0};
|
|
std::string details;
|
|
};
|
|
|
|
struct Task {
|
|
std::string name;
|
|
time_ns duration;
|
|
std::vector<size_t> section_indexes;
|
|
};
|
|
|
|
std::vector<Section> sections;
|
|
std::vector<Task> tasks;
|
|
|
|
time_ns start, end;
|
|
};
|
|
|
|
//
|
|
using ProfilerSectionIndex = size_t;
|
|
|
|
ProfilerSectionIndex BeginProfilerSection(const std::string &name, const std::string §ion_details = {});
|
|
void EndProfilerSection(ProfilerSectionIndex section_index);
|
|
|
|
void EndProfilerFrame();
|
|
const ProfilerFrame &GetLastFrameProfile();
|
|
|
|
//
|
|
class ProfilerPerfSection {
|
|
public:
|
|
ProfilerPerfSection(const std::string &task_name, const std::string §ion_details = {});
|
|
~ProfilerPerfSection();
|
|
private:
|
|
ProfilerSectionIndex section_index;
|
|
};
|
|
|
|
} // namespace hg
|