Profiler: Handle profiles with more kernel samples than user samples

Previously we assumed there were less kernel samples than user samples,
by implicitly using the kernel histogram size for indicies to the user
histogram. Such a profile can be reproduced by profiling a very short
lived program like true: `profile -c true`
This commit is contained in:
Idan Horowitz 2021-10-24 20:53:07 +03:00 committed by Andreas Kling
parent db68a52e23
commit 87bd98fe8e

View file

@ -167,11 +167,19 @@ void TimelineTrack::recompute_histograms_if_needed(HistogramInputs const& inputs
histogram.insert(clamp_timestamp(event.timestamp), 1 + event.lost_samples);
}
for (size_t bucket = 0; bucket < m_kernel_histogram->size(); bucket++) {
auto shorter_histogram_size = min(m_kernel_histogram->size(), m_user_histogram->size());
for (size_t bucket = 0; bucket < shorter_histogram_size; ++bucket) {
auto value = m_kernel_histogram->at(bucket) + m_user_histogram->at(bucket);
if (value > m_max_value)
m_max_value = value;
}
auto& longer_histogram = m_kernel_histogram->size() > m_user_histogram->size() ? *m_kernel_histogram : *m_user_histogram;
for (size_t bucket = shorter_histogram_size; bucket < longer_histogram.size(); ++bucket) {
auto value = longer_histogram.at(bucket);
if (value > m_max_value)
m_max_value = value;
}
}
float TimelineTrack::column_width() const