2022-06-16 13:56:10 +00:00
|
|
|
#pragma once
|
2022-06-16 13:57:05 +00:00
|
|
|
#include "FormatString/FormatString.hpp"
|
2022-06-16 13:56:10 +00:00
|
|
|
#include "sapphirepch.h"
|
2022-06-16 15:13:01 +00:00
|
|
|
#include <chrono>
|
2022-06-16 13:56:10 +00:00
|
|
|
|
|
|
|
/* Simple function to replace a substring in a string. */
|
|
|
|
bool replace(std::string& str, const std::string& from, const std::string& to);
|
|
|
|
|
|
|
|
/* Easy way of converting an int to a string without writing 5 lines of code every time you want to do it. */
|
|
|
|
std::string to_string(const int& value);
|
|
|
|
|
|
|
|
/* Easy way of converting a float to a string without writing 5 lines of code every time you want to do it. */
|
2022-06-16 15:13:01 +00:00
|
|
|
std::string to_string(const float& value);
|
|
|
|
|
|
|
|
/* Benchmarking utilities. */
|
|
|
|
|
|
|
|
class __benchmark_impl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
__benchmark_impl(std::string_view __function_name);
|
|
|
|
~__benchmark_impl();
|
|
|
|
|
|
|
|
static void enable();
|
|
|
|
static void disable();
|
|
|
|
|
|
|
|
static void init();
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> m_StartTimePoint;
|
|
|
|
std::string_view m_FunctionName;
|
|
|
|
static bool m_BenchmarkingEnabled;
|
|
|
|
bool m_InternalBenchmarkingEnabled;
|
|
|
|
};
|
|
|
|
|
2022-06-22 16:16:45 +00:00
|
|
|
#define benchmark(message) __benchmark_impl __benchmark_impl_timer(message)
|