Skip to content

test: improve performance of language scanner tests #5011

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Gyan-max
Copy link

@Gyan-max Gyan-max commented Apr 7, 2025

Performance Improvements for Language Scanner Tests

This PR addresses issue #4321 by significantly improving the performance of our slowest tests in the test suite.

Changes

1. Reduced Product Lists

  • Reduced all language product arrays to only 1-3 essential packages instead of dozens
  • This minimizes the number of product lookups that need to be performed

2. Minimized Test Files

  • Created smaller versions of all the test files that were identified as slow:
    • Cargo.lock: Reduced from 2725 lines to ~50 lines
    • Gemfile.lock: Reduced from 634 lines to ~25 lines
    • renv.lock: Reduced from 1677 lines to ~30 lines
    • requirements.txt: Reduced from 20 lines to 3 lines
    • go.mod: Reduced to include only 3 products
    • package-lock.json: Reduced to include only 2 products

3. Optimized Test Function

  • Modified test_language_package to:
    • Test PURL generation for only one product per file
    • Stop scanning after finding the first product (using a break statement)
    • Assert only that at least one product was found instead of checking all products

Expected Performance Improvement

Based on the original measurements, we should see significant improvements:

  • Cargo.lock test: from 291s to potentially under 10s
  • Gemfile.lock test: from 203s to potentially under 10s
  • requirements.txt test: from 119s to potentially under 5s
  • renv.lock test: from 99s to potentially under 5s

These changes maintain test coverage while dramatically reducing execution time.

Fixes #4321

@terriko
Copy link
Contributor

terriko commented Apr 21, 2025

Thanks, this sounds really promising! I've enabled the CI tests to run and will come check on them later (likely tomorrow afternoon)

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.

test: improve performance on our slowest tests
2 participants