-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
base: master
Are you sure you want to change the base?
Conversation
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
@milianw |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'<'); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got it ;-)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
ping? any progress on this front? |
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