Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_benchmarkbase.hpp
Go to the documentation of this file.
1#pragma once
2#include "../foray_basics.hpp"
3#include <vector>
4
5namespace foray::bench {
8 {
9 public:
10 static inline const char* BEGIN = "Begin";
11 static inline const char* END = "End";
12
14 const char* Id = "no Id";
17 };
18
21 {
22 public:
26 fp64_t End = 0.0;
28 std::vector<BenchmarkTimestamp> Timestamps;
30 std::vector<fp64_t> Deltas;
31
33 std::string PrintPretty(bool omitTimestamps = true) const;
35 std::string PrintCsvLine(char separator = ';', bool includeNewLine = true) const;
37 std::string PrintCsvHeader(char separator = ';', bool includeNewLine = true) const;
39 void PrintImGui(bool omitTimestamps = true);
40 };
41
44 {
45 public:
47
48 FORAY_GETTER_MR(Logs)
49 FORAY_GETTER_CR(Logs)
50
51 protected:
53 void Begin(fp64_t timestamp);
55 void LogTimestamp(const char* id, fp64_t timestamp);
57 void End(fp64_t timestamp);
58
59 std::vector<BenchmarkLog> mLogs;
61 bool mRecording = false;
62 };
63} // namespace foray::bench
Base class for all benchmark types.
Definition foray_benchmarkbase.hpp:44
BenchmarkLog mCurrentLog
Definition foray_benchmarkbase.hpp:60
void Begin(fp64_t timestamp)
Begins a new benchmark and records the "Begin" timestamp.
std::vector< BenchmarkLog > mLogs
Definition foray_benchmarkbase.hpp:59
void LogTimestamp(const char *id, fp64_t timestamp)
Logs timestamp of id.
void End(fp64_t timestamp)
Records the "End" timestamp and finalizes the benchmark.
bool mRecording
Definition foray_benchmarkbase.hpp:61
Log of a single benchmark run. All timestamps given must be relative to the same base time.
Definition foray_benchmarkbase.hpp:21
std::vector< fp64_t > Deltas
Deltas between the timestamps in milliseconds.
Definition foray_benchmarkbase.hpp:30
void PrintImGui(bool omitTimestamps=true)
Execute imgui command sequence to display the benchmark results.
std::string PrintCsvLine(char separator=';', bool includeNewLine=true) const
Prints all timestamps, separated by the separator character.
fp64_t End
Value of the last recorded timestamp.
Definition foray_benchmarkbase.hpp:26
fp64_t Begin
Value of the first recorded timestamp.
Definition foray_benchmarkbase.hpp:24
std::string PrintPretty(bool omitTimestamps=true) const
Prints a table with all timestamps and deltas, aswell as a total delta.
std::vector< BenchmarkTimestamp > Timestamps
List of timestamps in chronological order. Guaranteed to begin with BenchmarkTimestamp::Begin and end...
Definition foray_benchmarkbase.hpp:28
std::string PrintCsvHeader(char separator=';', bool includeNewLine=true) const
Prints all timestamps, separated by the separator character.
Timestamp combining a label / id with a timestamp in milliseconds.
Definition foray_benchmarkbase.hpp:8
static const char * BEGIN
Definition foray_benchmarkbase.hpp:10
fp64_t Timestamp
Timestamp in milliseconds.
Definition foray_benchmarkbase.hpp:16
static const char * END
Definition foray_benchmarkbase.hpp:11
const char * Id
Id of the data point for identification.
Definition foray_benchmarkbase.hpp:14
#define FORAY_GETTER_CR(member)
Return constant reference.
Definition foray_basics.hpp:60
#define FORAY_GETTER_MR(member)
Return mutable reference.
Definition foray_basics.hpp:54
Definition foray_bench_declares.hpp:3
double fp64_t
stdint.h style 64 bit floating point type alias (double)
Definition foray_basics.hpp:15