mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-16 21:04:20 +00:00
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:
parent
db68a52e23
commit
87bd98fe8e
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue