Skip to content

Commit

Permalink
[ui] added workaround for Qt memory leak on Linux when using multiple…
Browse files Browse the repository at this point in the history
… threads;

[ui] added median duration into tree stats;
[ui] added max rows count for "Call-stack" tree mode;
  • Loading branch information
cas4ey committed Oct 24, 2019
1 parent b4494bc commit c74744f
Show file tree
Hide file tree
Showing 19 changed files with 769 additions and 299 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ else ()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif ()

if (MSVC)
if (NOT (MSVC_VERSION LESS 1914))
# turn on valid __cplusplus macro value for visual studio (available since msvc 2017 update 7)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif ()
endif ()

option(EASY_PROFILER_NO_GUI "Build easy_profiler without the GUI application (required Qt)" OFF)

set(EASY_PROGRAM_VERSION_MAJOR 2)
Expand Down
23 changes: 23 additions & 0 deletions easy_profiler_core/include/easy/details/easy_compiler_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
# endif
#endif

#ifdef __cplusplus
# if __cplusplus >= 201703L
# define EASY_STD 17
# elif __cplusplus >= 201402L
# define EASY_STD 14
# else
# define EASY_STD 11
# endif
#else
# define EASY_STD 11
#endif


#if defined(_MSC_VER)
Expand Down Expand Up @@ -92,6 +103,10 @@
# define EASY_NOEXCEPT throw()
# endif

# if EASY_STD > 11 && _MSC_VER >= 1900
# define EASY_LAMBDA_MOVE_CAPTURE
# endif

# define EASY_FORCE_INLINE __forceinline

#elif defined(__clang__)
Expand Down Expand Up @@ -123,6 +138,10 @@
# define EASY_FINAL
# endif

# if EASY_STD > 11 && EASY_COMPILER_VERSION >= 34
# define EASY_LAMBDA_MOVE_CAPTURE
# endif

# define EASY_FORCE_INLINE inline __attribute__((always_inline))
# undef EASY_COMPILER_VERSION

Expand Down Expand Up @@ -160,6 +179,10 @@
# define EASY_FINAL
# endif

# if EASY_STD > 11 && EASY_COMPILER_VERSION >= 49
# define EASY_LAMBDA_MOVE_CAPTURE
# endif

# define EASY_FORCE_INLINE inline __attribute__((always_inline))
# undef EASY_COMPILER_VERSION

Expand Down
14 changes: 7 additions & 7 deletions easy_profiler_core/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ using async_future = std::future<async_result_t>;
template <class T>
struct Counter
{
T value = 0;
T count = 0;
};

struct Stats
Expand All @@ -147,7 +147,7 @@ struct Stats
Stats(profiler::BlockStatistics* stats_ptr, profiler::timestamp_t duration) EASY_NOEXCEPT
: stats(stats_ptr)
{
durations[duration].value = 1;
durations[duration].count = 1;
}

Stats(Stats&& another) EASY_NOEXCEPT
Expand Down Expand Up @@ -393,7 +393,7 @@ static profiler::BlockStatistics* update_statistics(
// write pointer to statistics into output (this is BlocksTree:: per_thread_stats or per_parent_stats or per_frame_stats)
auto stats = it->second.stats;
auto& durations = it->second.durations;
++durations[duration].value;
++durations[duration].count;

++stats->calls_number; // update calls number of this block
stats->total_duration += duration; // update summary duration of all block calls
Expand Down Expand Up @@ -457,7 +457,7 @@ static profiler::BlockStatistics* update_statistics(
auto stats = it->second.stats;
auto& durations = it->second.durations;

++durations[duration].value;
++durations[duration].count;

++stats->calls_number; // update calls number of this block
stats->total_duration += duration; // update summary duration of all block calls
Expand Down Expand Up @@ -515,7 +515,7 @@ static void calculate_medians(TStatsMapIterator begin, TStatsMapIterator end)
size_t total_count = 0;
for (auto& kv : durations)
{
total_count += kv.second.value;
total_count += kv.second.count;
}

auto stats = it->second.stats;
Expand All @@ -525,7 +525,7 @@ static void calculate_medians(TStatsMapIterator begin, TStatsMapIterator end)
size_t i = 0;
for (auto& kv : durations)
{
const auto count = kv.second.value;
const auto count = kv.second.count;

i += count;
if (i < index)
Expand All @@ -546,7 +546,7 @@ static void calculate_medians(TStatsMapIterator begin, TStatsMapIterator end)
bool i1 = false;
for (auto& kv : durations)
{
const auto count = kv.second.value;
const auto count = kv.second.count;

i += count;
if (i < index1)
Expand Down
Loading

0 comments on commit c74744f

Please sign in to comment.