Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kunitoki committed Aug 26, 2024
1 parent fd89fd4 commit eb770ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
27 changes: 8 additions & 19 deletions modules/juce_core/profiling/juce_Profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,21 @@ namespace juce

//==============================================================================

template <size_t sizeResult, size_t sizeTest>
template <std::size_t sizeResult, std::size_t sizeTest>
constexpr bool stringsEqual (const std::array<char, sizeResult>& result, const char (&test)[sizeTest])
{
static_assert (sizeTest > 1);
static_assert (sizeResult + 1 >= sizeTest);

std::string_view resultView (result.data(), sizeTest);
std::string_view testView (test, sizeTest);
return testView == resultView;
return std::string_view (test, sizeTest) == std::string_view (result.data(), sizeTest);
}

static_assert (stringsEqual (Profiler::compileTimePrettierFunction ([]
{
return "int main";
}),
"main"));
static_assert (stringsEqual (Profiler::compileTimePrettierFunction ([]
{
return "void AudioProcessor::processBlock(juce::AudioBuffer<float> &, juce::MidiBuffer &)::(anonymous class)::operator()()::(anonymous class)::operator()(uint32_t) const";
}),
"AudioProcessor::processBlock"));
static_assert (stringsEqual (Profiler::compileTimePrettierFunction ([]
{
return "void __cdecl AudioProcessor::processBlock::<lambda_1>::operator";
}),
"AudioProcessor::processBlock"));
// clang-format off
static_assert (stringsEqual (Profiler::compileTimePrettierFunction ([] { return "int main"; }), "main"));
static_assert (stringsEqual (Profiler::compileTimePrettierFunction ([] { return "void AudioProcessor::processBlock(juce::AudioBuffer<float> &, juce::MidiBuffer &)::(anonymous class)::operator()()::(anonymous class)::operator()(uint32_t) const"; }), "AudioProcessor::processBlock"));
static_assert (stringsEqual (Profiler::compileTimePrettierFunction ([] { return "void __cdecl AudioProcessor::processBlock::<lambda_1>::operator"; }), "AudioProcessor::processBlock"));
static_assert (stringsEqual (Profiler::compileTimePrettierFunction ([] { return "void __fastcall AudioProcessor::processBlock::<lambda_1>::operator"; }), "AudioProcessor::processBlock"));
// clang-format on

//==============================================================================

Expand Down
16 changes: 8 additions & 8 deletions modules/juce_core/profiling/juce_Profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ constexpr auto Profiler::compileTimePrettierFunction (F func)
}
} // namespace juce

/**
// clang-format off
/**
Starts profiling/tracing with the given arguments.
This macro is used to start a profiling session using the JUCE Profiler.
Expand All @@ -145,14 +146,14 @@ constexpr auto Profiler::compileTimePrettierFunction (F func)
*/
#define YUP_PROFILE_START(...) ::juce::Profiler::getInstance()->startTracing (__VA_ARGS__)

/** Stops the profiling/tracing session.
/** Stops the profiling/tracing session.
This macro stops the current profiling session using the JUCE Profiler.
It calls the `stopTracing` function of the `Profiler` singleton.
*/
#define YUP_PROFILE_STOP(...) ::juce::Profiler::getInstance()->stopTracing()

/** Records a profiling trace event.
/** Records a profiling trace event.
This macro is used to trace events for profiling purposes.
If tracing is enabled, it generates a trace event with the specified category and optional additional arguments.
Expand All @@ -162,14 +163,13 @@ constexpr auto Profiler::compileTimePrettierFunction (F func)
@param ... Optional additional arguments for the trace event.
*/
#if ! YUP_PROFILE_DISABLE_TRACE
#define YUP_PROFILE_TRACE(category, ...) \
constexpr auto JUCE_JOIN_MACRO (juce_pfn_, __LINE__) = ::juce::Profiler::compileTimePrettierFunction ([] { \
return PERFETTO_DEBUG_FUNCTION_IDENTIFIER(); \
}); \
TRACE_EVENT (category, ::perfetto::StaticString (JUCE_JOIN_MACRO (juce_pfn_, __LINE__).data()), ##__VA_ARGS__)
#define YUP_PROFILE_TRACE(category, ...) \
constexpr auto JUCE_JOIN_MACRO (juce_pfn_, __LINE__) = ::juce::Profiler::compileTimePrettierFunction ([] { return PERFETTO_DEBUG_FUNCTION_IDENTIFIER(); }); \
TRACE_EVENT (category, ::perfetto::StaticString (JUCE_JOIN_MACRO (juce_pfn_, __LINE__).data()), ##__VA_ARGS__)
#else
#define YUP_PROFILE_TRACE(category, ...)
#endif
// clang-format on

#else
#define YUP_PROFILE_START(...)
Expand Down

0 comments on commit eb770ab

Please sign in to comment.