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

perf tool enhancement #1545

Merged
merged 3 commits into from
Jan 10, 2025
Merged

perf tool enhancement #1545

merged 3 commits into from
Jan 10, 2025

Conversation

Tofel
Copy link
Contributor

@Tofel Tofel commented Jan 9, 2025

Direct query comparison:

  • add threshold validation,
  • nil report validation,
  • better readability for infinite metric change (999% instead of 100% since in reality the change is infinite)
  • couple more unit tests for edge cases

Below is a summarization created by an LLM (gpt-4-0125-preview). Be mindful of hallucinations and verify accuracy.

Why

The changes refine the calculation of percentage differences, especially for edge cases where previous values are zero, and enhance the validation and comparison logic in the benchmark spy reporting functionality. This includes handling cases with nil reports, incorrect thresholds, and transitions from zero to non-zero values more gracefully, which improves the accuracy and reliability of performance comparison over time.

What

  • wasp/benchspy/report.go
    • Modified calculateDiffPercentage function to handle edge cases, especially when the previous value is 0, by introducing conventions for infinite changes and complete improvements.
    • Added checks in CompareDirectWithThresholds to immediately return errors if one or both reports are nil, ensuring the function handles uninitialized reports.
    • Introduced validateThresholds function to ensure that the thresholds for median, P95, max latency, and error rate are within the acceptable range of 0 to 100.
  • wasp/benchspy/report_test.go
    • Enhanced test cases to cover new scenarios, including handling of nil reports, incorrect threshold values, zero to non-zero transitions, and non-zero to zero transitions. This ensures the new logic behaves as expected under a wide range of conditions.

@Tofel Tofel marked this pull request as ready for review January 10, 2025 10:09
@Tofel Tofel requested review from sebawo and a team as code owners January 10, 2025 10:09
@Tofel
Copy link
Contributor Author

Tofel commented Jan 10, 2025

code duplication content is related to unit tests, not gonna fix it 🤷

wasp/benchspy/report.go Outdated Show resolved Hide resolved
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
61.6% Duplication on New Code (required ≤ 5%)

See analysis details on SonarQube

@Tofel Tofel merged commit da0bb13 into main Jan 10, 2025
52 of 55 checks passed
@Tofel Tofel deleted the perf-tool-extra branch January 10, 2025 15:19
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.

3 participants