diff options
author | Tim Henning <[email protected]> | 2019-10-17 16:20:13 +0200 |
---|---|---|
committer | Tim Henning <[email protected]> | 2019-10-24 08:47:57 +0000 |
commit | 1673e692c5447c78bca9400fe6e3495fda042e39 (patch) | |
tree | 3cc3ae43a5e6b947f15c2d165b591e758d49c627 /src/plugins/ctfvisualizer/ctftracemanager.cpp | |
parent | b90200cb195d0fc30aba6782b9bb921ae6e91d17 (diff) |
Tracing: CtfVisualizer: Apply thread restrictions to statistics, too
The statistics are now also filtered by the selected threads. If no
thread is selected, the statistics are presented for all threads combined.
This fixes a bug with double counted events, too.
Change-Id: I9afa0bf5bc85ccf363e00600e75001c0ab3f2e8a
Reviewed-by: Ulf Hermann <[email protected]>
Diffstat (limited to 'src/plugins/ctfvisualizer/ctftracemanager.cpp')
-rw-r--r-- | src/plugins/ctfvisualizer/ctftracemanager.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/plugins/ctfvisualizer/ctftracemanager.cpp b/src/plugins/ctfvisualizer/ctftracemanager.cpp index 493fbff7402..382fe544387 100644 --- a/src/plugins/ctfvisualizer/ctftracemanager.cpp +++ b/src/plugins/ctfvisualizer/ctftracemanager.cpp @@ -146,7 +146,6 @@ void CtfTraceManager::addEvent(const json &event) if (visibleOnTimeline) { m_traceBegin = std::min(m_traceBegin, timestamp); m_traceEnd = std::max(m_traceEnd, timestamp); - m_statisticsModel->addEvent(event, result.second); } else if (m_timeOffset == timestamp) { // this timestamp was used as the time offset but it is not a visible element // -> reset the time offset again: @@ -169,10 +168,9 @@ void CtfVisualizer::Internal::CtfTraceManager::load(const QString &filename) json::parser_callback_t callback = [&ctfParser](int depth, json::parse_event_t event, json &parsed) { return ctfParser.callback(depth, event, parsed); }; - m_statisticsModel->beginLoading(); json unusedValues = json::parse(file, callback, /*allow_exceptions*/ false); - m_statisticsModel->endLoading(); file.close(); + updateStatistics(); } void CtfTraceManager::finalize() @@ -264,6 +262,27 @@ void CtfTraceManager::addModelsToAggregator() modelsToAdd.append(QVariant::fromValue(model)); } m_modelAggregator->setModels(modelsToAdd); + updateStatistics(); +} + +void CtfTraceManager::updateStatistics() +{ + const bool showAll = std::none_of(m_threadRestrictions.begin(), m_threadRestrictions.end(), [](bool value) { + return value; + }); + + m_statisticsModel->beginLoading(); + for (auto thread : m_threadModels) { + if (showAll || m_threadRestrictions[thread->tid()]) + { + const int eventCount = thread->count(); + for (int i = 0; i < eventCount; ++i) { + QString title = thread->eventTitle(i); + m_statisticsModel->addEvent(title, thread->duration(i)); + } + } + } + m_statisticsModel->endLoading(); } void CtfTraceManager::clearAll() |