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

Added new flags for timings #3246

Merged
merged 11 commits into from
Aug 5, 2023
Merged

Conversation

WalshyDev
Copy link
Member

@WalshyDev WalshyDev commented Sep 12, 2021

Description

Timings are pretty cool however we can't currently change the order. Now, we can!
This PR allows for 2 new flags --avg and --low. --avg will order the timings based on average rather than total. --low will order the timings lowest to highest.

In Action

Default (no flags)
default

Average (--avg)
avg

Low (--low)
low

Proposed changes

Instead of just adding average I decided to make a proper way so that we can add more ordering later. Due to me doing it this way I also added low.

  • Created SummaryOrderType
  • Added PerformanceInspector#getOrderType
  • Added sortTimings in PerformanceSummary
  • Docs improvement

Still to do

  • Improve docs - please suggest a better message
  • Improve the mess of average sorting
    return stream
    .map(entry -> {
    int count = profiler.getBlocksOfId(entry.getKey());
    long avg = count > 0 ? entry.getValue() / count : entry.getValue();
    return new Pair<>(entry.getKey(), avg);
    })
    .collect(Collectors.toMap(Pair::getFirstValue, Pair::getSecondValue))
    .entrySet()
    .stream()
    .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
    .collect(Collectors.toList());
    }

Related Issues (if applicable)

N/A

Checklist

  • I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • I followed the existing code standards and didn't mess up the formatting.
  • I did my best to add documentation to any public classes or methods I added.
  • I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • I added sufficient Unit Tests to cover my code.

@WalshyDev WalshyDev requested a review from a team as a code owner September 12, 2021 09:00
@github-actions github-actions bot added the 🎈 Feature This Pull Request adds a new feature. label Sep 12, 2021
@github-actions
Copy link
Contributor

Your Pull Request was automatically labelled as: "🎈 Feature"
Thank you for contributing to this project! ❤️

@TheBusyBiscuit TheBusyBiscuit self-assigned this Sep 12, 2021
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

1.5% 1.5% Coverage
0.0% 0.0% Duplication

Copy link
Member

@TheBusyBiscuit TheBusyBiscuit left a comment

Choose a reason for hiding this comment

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

Generally I am approving this.
I just wanna discuss two points regarding the SummaryOrderType enum before merging

@TheBusyBiscuit TheBusyBiscuit added the ⏰ Waiting for response We are waiting for a response. label Dec 20, 2021
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

1.4% 1.4% Coverage
0.0% 0.0% Duplication

TheBusyBiscuit
TheBusyBiscuit previously approved these changes Jan 7, 2022
@TheBusyBiscuit TheBusyBiscuit removed the ⏰ Waiting for response We are waiting for a response. label Jan 7, 2022
Copy link
Contributor

@char3210 char3210 left a comment

Choose a reason for hiding this comment

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

looks good

am i allowed to do this

@svr333 svr333 self-assigned this Jan 19, 2022
@TheBusyBiscuit TheBusyBiscuit added the ⏰ Waiting for response We are waiting for a response. label Jul 10, 2022
@TheBusyBot TheBusyBot added the ⚡ Merge Conflicts This Pull Request has merged conflicts which need to be resolved! label Jul 19, 2022
@WalshyDev WalshyDev added 🎯 Needs testing This Issue needs to be tested by our team to see if it can be reproduced. and removed ⚡ Merge Conflicts This Pull Request has merged conflicts which need to be resolved! ⏰ Waiting for response We are waiting for a response. labels Jul 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2023

Slimefun preview build

A Slimefun preview build is available for testing!
Commit: 84c075b9

https://preview-builds.walshy.dev/download/Slimefun/3246/84c075b9

Note: This is not a supported build and is only here for the purposes of testing.
Do not run this on a live server and do not report bugs anywhere but this PR!

J3fftw1
J3fftw1 previously approved these changes Jul 9, 2023
@Boomer-1
Copy link

Boomer-1 commented Jul 9, 2023

here's the results of my testing with a small amount of items

with --avg
image

with --low
image

appears to be working

@Boomer-1 Boomer-1 added Build tested Used to indicate the PR preview build has been tested by one of the team and removed 🎯 Needs testing This Issue needs to be tested by our team to see if it can be reproduced. labels Jul 9, 2023
@J3fftw1
Copy link
Contributor

J3fftw1 commented Jul 29, 2023

can we get some reviews on this?

…/profiler/inspectors/PlayerPerformanceInspector.java

Co-authored-by: JustAHuman-xD <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

1.3% 1.3% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@JustAHuman-xD JustAHuman-xD left a comment

Choose a reason for hiding this comment

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

LGTM just one really optional change

*/
public PlayerPerformanceInspector(@Nonnull Player player) {
public PlayerPerformanceInspector(@Nonnull Player player, @Nonnull SummaryOrderType orderType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can still use parameters are nonnull by default but other than that this looks good to me

@WalshyDev WalshyDev merged commit 8bcf073 into master Aug 5, 2023
@WalshyDev WalshyDev deleted the feature/avg-and-low-timings-flags branch August 5, 2023 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build tested Used to indicate the PR preview build has been tested by one of the team 🎈 Feature This Pull Request adds a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants