-
-
Notifications
You must be signed in to change notification settings - Fork 210
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "middleelide.h" | ||
#include <QChar> | ||
|
||
MiddleElide::MiddleElide() | ||
{ | ||
|
||
} | ||
|
||
QString MiddleElide::elideAngleBracket(const QString& s) | ||
{ | ||
return substituteAngleBrackets(s); | ||
} | ||
|
||
QString MiddleElide::substituteAngleBrackets(const QString& s) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should just be a free function within There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
static QChar startBracket = QChar(u'<'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to make this static, and use
|
||
static QChar stopBracket = QChar(u'>'); | ||
|
||
int level = 0; | ||
QString result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
for (int i=0, n = s.length(); i < n; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
QChar currentChar = s[i]; | ||
if (currentChar == QChar(startBracket) && level == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. simplify:
|
||
result += QChar(startBracket); | ||
level++; | ||
} | ||
else if (currentChar == QChar(startBracket) && level > 0) { | ||
level++; | ||
} | ||
else if (currentChar == QChar(stopBracket) && level == 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dito |
||
result += QString::fromUtf8("...>"); | ||
level--; | ||
} | ||
else if (currentChar == QChar(stopBracket) && level > 1) { | ||
level--; | ||
} | ||
else if (level == 0) { | ||
result += currentChar; | ||
} | ||
} | ||
return result; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef MIDDLEELIDE_H | ||
#define MIDDLEELIDE_H | ||
|
||
#include <QString> | ||
|
||
class MiddleElide | ||
{ | ||
public: | ||
MiddleElide(); | ||
|
||
static QString elideAngleBracket(const QString& s); | ||
|
||
private: | ||
static QString substituteAngleBrackets(const QString& s); | ||
}; | ||
|
||
#endif // MIDDLEELIDE_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
project(test_middle_elide LANGUAGES CXX) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this, instead add the test to |
||
|
||
find_package(QT NAMES Qt5 Qt6 COMPONENTS Test REQUIRED) | ||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Test REQUIRED) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
enable_testing() | ||
|
||
add_executable(test_middle_elide | ||
tst_middle_elide.cpp | ||
) | ||
|
||
add_test(NAME test_middle_elide COMMAND test_middle_elide) | ||
|
||
target_link_libraries(test_middle_elide PRIVATE | ||
heaptrack_gui_private | ||
Qt${QT_VERSION_MAJOR}::Test) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <QtTest> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing license header |
||
#include <QString> | ||
#include "analyze/gui/middleelide.h" | ||
|
||
// add necessary includes here | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
|
||
const char* simple_case = "MainWindow::onLoadingFinish(unsigned int&)"; | ||
const char* one_bracket = "std::vector<test type in bracket> MainWindow::onLoadingFinish(unsigned int&)"; | ||
const char* one_bracket_fixed = "std::vector<...> MainWindow::onLoadingFinish(unsigned int&)"; | ||
const char* two_brackets = "std::vector<test type in bracket> MainWindow<vector_a>::onLoadingFinish(unsigned int&)"; | ||
const char* two_brackets_fixed = "std::vector<...> MainWindow<...>::onLoadingFinish(unsigned int&)"; | ||
const char* nested_brackets = "std::vector<test type <int> in bracket> MainWindow::onLoadingFinish(unsigned int&)"; | ||
const char* nested_brackets_fixed = "std::vector<...> MainWindow::onLoadingFinish(unsigned int&)"; | ||
|
||
|
||
class test_initilaize : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
test_initilaize() = default; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed, remove |
||
~test_initilaize() = default; | ||
|
||
private slots: | ||
void test_simple_case(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use data driven tests instead ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am familiar with the data-driven tests of the QtTest framework. This approach (originally from TDD) describes the tests much more clearly than a data-driven approach with only one method. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
||
void test_single_bracket(); | ||
void test_multiple_brackets(); | ||
void test_nested_brackets(); | ||
}; | ||
|
||
void test_initilaize::test_simple_case() | ||
{ | ||
QString testString = QString::fromUtf8(simple_case); | ||
QString result = MiddleElide::elideAngleBracket(testString); | ||
QVERIFY(result == testString); | ||
} | ||
|
||
void test_initilaize::test_single_bracket() | ||
{ | ||
QString testString = QString::fromUtf8(one_bracket); | ||
QString testStringFixed = QString::fromUtf8(one_bracket_fixed); | ||
QString result = MiddleElide::elideAngleBracket(testString); | ||
QVERIFY(result == testStringFixed); | ||
} | ||
|
||
void test_initilaize::test_multiple_brackets() | ||
{ | ||
QString testString = QString::fromUtf8(two_brackets); | ||
QString testStringFixed = QString::fromUtf8(two_brackets_fixed); | ||
QString result = MiddleElide::elideAngleBracket(testString); | ||
QVERIFY(result == testStringFixed); | ||
} | ||
|
||
void test_initilaize::test_nested_brackets() | ||
{ | ||
QString testString = QString::fromUtf8(nested_brackets); | ||
QString testStringFixed = QString::fromUtf8(nested_brackets_fixed); | ||
QString result = MiddleElide::elideAngleBracket(testString); | ||
QVERIFY(result == testStringFixed); | ||
} | ||
|
||
QTEST_APPLESS_MAIN(test_initilaize) | ||
|
||
#include "tst_middle_elide.moc" |
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