Skip to content

Add code for cost delegate #34

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Mar 2, 2017
Merged

Add code for cost delegate #34

merged 1 commit into from
Mar 2, 2017

Conversation

nwrogers
Copy link
Contributor

Bring in and adapt Heaptracks cost delegate for Hotspot

#23

Copy link
Member

@milianw milianw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also reword the commit message:

Add cost delegate to visualize percentages graphically

This commit introduces the cost delegate from heaptrack
and adapts it for usage in hotspot.

Fixes: #23

auto bottomUpCostModel = new BottomUpModel(this);
setupTreeView(ui->bottomUpTreeView, ui->bottomUpSearch, bottomUpCostModel);
ui->bottomUpTreeView->setItemDelegate(costDelegate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm, don't we only want to set that for the cost columns? This sets it for all columns - is that correct? I don't think so.

void CostDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
// TODO: handle negative values
const int64_t cost = index.data(AbstractTreeModel::SortRole).toULongLong();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use auto, note how you get an unsigned value but store it in a signed int64_t

return;
}

const int64_t totalCost = index.data(AbstractTreeModel::TotalCostRole).toULongLong();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

}

const int64_t totalCost = index.data(AbstractTreeModel::TotalCostRole).toULongLong();
// top-down can miscalculate the peak cost
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might actually not be required anymore - could you check whether removing the std::min(1, ) wrapper? the abs and division is still fine though.


#include "costdelegate.h"

#include "treemodel.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this delegate also needs to support the hashmodel (for caller/callee), we must not let it depend on the treemodel

instead, pass in the roles to query via the ctor, store them in member variables, and then use that below.

this also means you'll need two delegates in the mainwindow: one for all tree models, and one for all hashmodels.

This commit introduces the cost delegate from heaptrack and adapts it
for usage in hotspot.

Fixes: KDAB#23
@nwrogers
Copy link
Contributor Author

nwrogers commented Mar 1, 2017

Fixes made, comment updated, and I tested std:min. At least with the perf.data file I am testing with the results were identical for every result so I went ahead and removed the std::min wrapper

Copy link
Member

@milianw milianw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent, thank you

@milianw milianw merged commit 8864415 into KDAB:master Mar 2, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants