Changeset View
Changeset View
Standalone View
Standalone View
src/analyze/gui/parser.cpp
Show First 20 Lines • Show All 294 Lines • ▼ Show 20 Line(s) | 290 | if (recursionIt == recursionGuard->end()) { | |||
---|---|---|---|---|---|
295 | if (recursionGuard->isEmpty()) { | 295 | if (recursionGuard->isEmpty()) { | ||
296 | // increment self cost for leaf | 296 | // increment self cost for leaf | ||
297 | locationCost.selfCost += cost; | 297 | locationCost.selfCost += cost; | ||
298 | } | 298 | } | ||
299 | recursionGuard->insert(location.symbol); | 299 | recursionGuard->insert(location.symbol); | ||
300 | } | 300 | } | ||
301 | } | 301 | } | ||
302 | 302 | | |||
303 | std::pair<TreeData, CallerCalleeResults> mergeAllocations(const ParserData& data) | 303 | std::pair<TreeData, CallerCalleeResults> mergeAllocations(Parser *parser, const ParserData& data) | ||
304 | { | 304 | { | ||
305 | CallerCalleeResults callerCalleeResults; | 305 | CallerCalleeResults callerCalleeResults; | ||
306 | TreeData topRows; | 306 | TreeData topRows; | ||
307 | QSet<Symbol> symbolRecursionGuard; | 307 | QSet<Symbol> symbolRecursionGuard; | ||
308 | auto addRow = [&symbolRecursionGuard, &callerCalleeResults](TreeData* rows, const Location& location, | 308 | auto addRow = [&symbolRecursionGuard, &callerCalleeResults](TreeData* rows, const Location& location, | ||
309 | const Allocation& cost) -> TreeData* { | 309 | const Allocation& cost) -> TreeData* { | ||
310 | auto it = lower_bound(rows->begin(), rows->end(), location.symbol); | 310 | auto it = lower_bound(rows->begin(), rows->end(), location.symbol); | ||
311 | if (it != rows->end() && it->symbol == location.symbol) { | 311 | if (it != rows->end() && it->symbol == location.symbol) { | ||
312 | it->cost += cost; | 312 | it->cost += cost; | ||
313 | } else { | 313 | } else { | ||
314 | it = rows->insert(it, {cost, location.symbol, nullptr, {}}); | 314 | it = rows->insert(it, {cost, location.symbol, nullptr, {}}); | ||
315 | } | 315 | } | ||
316 | addCallerCalleeEvent(location, cost, &symbolRecursionGuard, &callerCalleeResults); | 316 | addCallerCalleeEvent(location, cost, &symbolRecursionGuard, &callerCalleeResults); | ||
317 | return &it->children; | 317 | return &it->children; | ||
318 | }; | 318 | }; | ||
319 | const auto allocationCount = data.allocations.size(); | ||||
320 | const auto onePercent = qMax<decltype(allocationCount)>(1, allocationCount / 100); | ||||
mwolff: std::max<size_t>(1, ...) would be how I write it. please at least std::max | |||||
321 | auto progress = 0; | ||||
319 | // merge allocations, leave parent pointers invalid (their location may change) | 322 | // merge allocations, leave parent pointers invalid (their location may change) | ||
320 | for (const auto& allocation : data.allocations) { | 323 | for (const auto& allocation : data.allocations) { | ||
321 | auto traceIndex = allocation.traceIndex; | 324 | auto traceIndex = allocation.traceIndex; | ||
322 | auto rows = &topRows; | 325 | auto rows = &topRows; | ||
323 | unordered_set<uint32_t> recursionGuard; | 326 | unordered_set<uint32_t> recursionGuard; | ||
324 | recursionGuard.insert(traceIndex.index); | 327 | recursionGuard.insert(traceIndex.index); | ||
325 | symbolRecursionGuard.clear(); | 328 | symbolRecursionGuard.clear(); | ||
326 | while (traceIndex) { | 329 | while (traceIndex) { | ||
Show All 9 Lines | 338 | if (data.isStopIndex(ip.frame.functionIndex)) { | |||
336 | break; | 339 | break; | ||
337 | } | 340 | } | ||
338 | traceIndex = trace.parentIndex; | 341 | traceIndex = trace.parentIndex; | ||
339 | if (!recursionGuard.insert(traceIndex.index).second) { | 342 | if (!recursionGuard.insert(traceIndex.index).second) { | ||
340 | qWarning() << "Trace recursion detected - corrupt data file?"; | 343 | qWarning() << "Trace recursion detected - corrupt data file?"; | ||
341 | break; | 344 | break; | ||
342 | } | 345 | } | ||
343 | } | 346 | } | ||
347 | ++progress; | ||||
348 | if ((progress % onePercent) == 0) { | ||||
349 | const int percent = progress * 100 / allocationCount; | ||||
350 | emit parser->progressMessageAvailable(i18n("merging allocations... %1%", percent)); | ||||
351 | } | ||||
344 | } | 352 | } | ||
345 | // now set the parents, the data is constant from here on | 353 | // now set the parents, the data is constant from here on | ||
346 | setParents(topRows, nullptr); | 354 | setParents(topRows, nullptr); | ||
347 | 355 | | |||
348 | return {topRows, callerCalleeResults}; | 356 | return {topRows, callerCalleeResults}; | ||
349 | } | 357 | } | ||
350 | 358 | | |||
351 | RowData* findBySymbol(const RowData& row, QVector<RowData>* data) | 359 | RowData* findBySymbol(const RowData& row, QVector<RowData>* data) | ||
▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Line(s) | 568 | stream() << make_job([this, path, diffBase]() { | |||
584 | data->updateStringCache(); | 592 | data->updateStringCache(); | ||
585 | 593 | | |||
586 | emit summaryAvailable({QString::fromStdString(data->debuggee), data->totalCost, data->totalTime, data->peakTime, | 594 | emit summaryAvailable({QString::fromStdString(data->debuggee), data->totalCost, data->totalTime, data->peakTime, | ||
587 | data->peakRSS * data->systemInfo.pageSize, | 595 | data->peakRSS * data->systemInfo.pageSize, | ||
588 | data->systemInfo.pages * data->systemInfo.pageSize, data->fromAttached}); | 596 | data->systemInfo.pages * data->systemInfo.pageSize, data->fromAttached}); | ||
589 | 597 | | |||
590 | emit progressMessageAvailable(i18n("merging allocations...")); | 598 | emit progressMessageAvailable(i18n("merging allocations...")); | ||
591 | // merge allocations before modifying the data again | 599 | // merge allocations before modifying the data again | ||
592 | const auto mergedAllocations = mergeAllocations(*data); | 600 | const auto mergedAllocations = mergeAllocations(this, *data); | ||
593 | emit bottomUpDataAvailable(mergedAllocations.first); | 601 | emit bottomUpDataAvailable(mergedAllocations.first); | ||
594 | 602 | | |||
595 | // also calculate the size histogram | 603 | // also calculate the size histogram | ||
596 | emit progressMessageAvailable(i18n("building size histogram...")); | 604 | emit progressMessageAvailable(i18n("building size histogram...")); | ||
597 | const auto sizeHistogram = buildSizeHistogram(*data); | 605 | const auto sizeHistogram = buildSizeHistogram(*data); | ||
598 | emit sizeHistogramDataAvailable(sizeHistogram); | 606 | emit sizeHistogramDataAvailable(sizeHistogram); | ||
599 | // now data can be modified again for the chart data evaluation | 607 | // now data can be modified again for the chart data evaluation | ||
600 | 608 | | |||
Show All 29 Lines |
std::max<size_t>(1, ...) would be how I write it. please at least std::max