Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bug 379660 Remove template parameters from flamegraph view #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

khReichel
Copy link

Added a textfilter which removes the long template parameters as
described in the Bug ticket Bug 379660.
Added unit-tests for filtering the entries and removing the template parameters

Added a textfilter which removes the long template parameters as
described in the Bug ticket Bug 379660.
Added unit-tests for filtering the entries and removing the template parameters
@khReichel
Copy link
Author

@milianw
I have implemented the patch for omitting the template parameters from the flame view (but not from the tooltips, where the information is really necessary).
If you would like to, please add my contribution.
If there is something you would like to have changed, please let me know

Copy link
Collaborator

@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.

hey, thanks for your contribution. there are some ways this could be simplified, but otherwise it's already looking good to me.

return substituteAngleBrackets(s);
}

QString MiddleElide::substituteAngleBrackets(const QString& s)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should just be a free function within analyze/gui/util.h - there's no need to put this into a separate file and into a class namespace

Copy link
Author

Choose a reason for hiding this comment

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

I was not sure if util.h is the right place for the method.
But it is ok for me


QString MiddleElide::substituteAngleBrackets(const QString& s)
{
static QChar startBracket = QChar(u'<');
Copy link
Collaborator

Choose a reason for hiding this comment

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

no need to make this static, and use QLatin1Char please:

const auto startBracket = QLatin1Char('<');

static QChar stopBracket = QChar(u'>');

int level = 0;
QString result;
Copy link
Collaborator

Choose a reason for hiding this comment

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

result.reserve(s.size())


int level = 0;
QString result;
for (int i=0, n = s.length(); i < n; i++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

for (auto currentChar : s)

QString result;
for (int i=0, n = s.length(); i < n; i++) {
QChar currentChar = s[i];
if (currentChar == QChar(startBracket) && level == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

simplify:

if (currentChar == startBracket) {
    if (level == 0) {
        result += startBracket;
    }
    ++level;
} else if (currentChar == stopBracket) {
    if (level == 1) {
        result += stopBracket;
    }
    --level;
} else if (level == 0) {
    result += currentChar;
}

#include <QString>
#include "analyze/gui/middleelide.h"

// add necessary includes here
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

@@ -0,0 +1,64 @@
#include <QtTest>
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing license header

~test_initilaize() = default;

private slots:
void test_simple_case();
Copy link
Collaborator

Choose a reason for hiding this comment

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

use data driven tests instead (QTest::add{Column,Row} & friends)

Copy link
Author

Choose a reason for hiding this comment

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

I am familiar with the data-driven tests of the QtTest framework.
However, I wanted to name the individual tests explicitly.
For me, it is much clearer to have individual tests that precisely describe the individual test case.
(e.g. test_single_bracket(), test_multiple_brackets()).

This approach (originally from TDD) describes the tests much more clearly than a data-driven approach with only one method.
What would still be possible in any case is a summary of the redundant code of the individual test methods.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't follow, the rows get a label which would have the same explanation, no? i.e. to me, the following has the same level of detail:

testElideTemplates:single_bracket

testElideTemplates_singleBracket

Q_OBJECT

public:
test_initilaize() = default;
Copy link
Collaborator

Choose a reason for hiding this comment

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

not needed, remove

@@ -192,10 +193,12 @@ void FrameGraphicsItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*
Q_UNREACHABLE();
}();

QString middleElidedLabel = MiddleElide::elideAngleBracket(label);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this functionality needs to be optional, and should be off-by-default. please add a setting and a gui checkbox to enable it

Copy link
Author

Choose a reason for hiding this comment

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

Ok, got it ;-)

Copy link
Author

Choose a reason for hiding this comment

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

@milianw Is there some persistancy functionality available in heaptrac.
Otherwise I will use QSettings for storing that elide functionality

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, see MainWindow::m_config

@milianw
Copy link
Collaborator

milianw commented Dec 19, 2021

ping? any progress on this front?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants