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

some refactoring #453

Merged
merged 2 commits into from
Jan 17, 2025
Merged

some refactoring #453

merged 2 commits into from
Jan 17, 2025

Conversation

jmlich
Copy link
Contributor

@jmlich jmlich commented Jan 17, 2025

I was trying to find out reason why the SportSummaryPage is rendered slowly. I have improved code a little. Here are changes explained one by one

Amazfish::activityToString:

  • multiple if() changed to switch(). I think it is easier to read and easier for compiler to optimize.

HeartratePage.qml:

  • I was confused, because SportsSummary page is loaded already when Heartrate page is shown
  • var -> real - for qml compiler are optimizations easier
  • var point = points[i]; In my other project I have spotted significant performance improvement. However, doesn't feel better.

SportsSummaryPage.qml:

  • listItem.width -> it was hard to read for me until I figured out that is belongs to previous line.

SportsDataModel::data()

  • I have changed condition if (index.row() < 0 || index.row() > m_data.length()) { to return early, because I don't like code which is indenting into the deepness.
  • I have switched if to switch-case
  • I have used separate variable const SportsData &item = m_data.at(index.row()); to improve readability.

sportsdatamodel.cpp:

  • the bottleneck is "here", so I have added QElapsedTimer, but I guess this is not available in Qt 5.6, so I have removed it
  • the query usually took less than 0.2 seconds
  • my finding is that SportsDataModel::update() takes ~2 seconds on endResetModel(); line. I guess, this means that rendering of updated model is slow.
  • I have tried to comment out some items (timeImage, timeLabel, distanceImage, distanceLabel) in delegate and it really helped, but this is task for future myself.

@piggz
Copy link
Owner

piggz commented Jan 17, 2025

brilliant, thanks!

@piggz piggz merged commit d041569 into piggz:master Jan 17, 2025
7 checks passed
@jmlich jmlich deleted the refactoring branch January 17, 2025 14:38
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