Skip to content

Conversation

@misrasaurabh1
Copy link
Contributor

@misrasaurabh1 misrasaurabh1 commented Apr 16, 2025

PR Type

  • Enhancement

Description

  • Add timing measurement for test discovery

  • Log elapsed time in test discovery output


Changes walkthrough 📝

Relevant files
Enhancement
optimizer.py
Add timing measurement for test discovery.                             

codeflash/optimization/optimizer.py

  • Imported the time module.
  • Captured start time before test discovery.
  • Updated logging to report elapsed time.
  • +3/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Time Formatting

    Consider formatting the elapsed time output to improve readability instead of displaying a raw float value. Storing the elapsed time in a variable and then formatting it (e.g., rounding to two decimals) could provide clearer log messages.

    start_time = time.time()
    function_to_tests: dict[str, list[FunctionCalledInTest]] = discover_unit_tests(self.test_cfg)
    num_discovered_tests: int = sum([len(value) for value in function_to_tests.values()])
    console.rule()
    logger.info(f"Discovered {num_discovered_tests} existing unit tests in {time.time() - start_time}s at {self.test_cfg.tests_root}")

    @github-actions
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Format elapsed time output

    Capture the elapsed time in a variable and format it to two decimals for more
    consistent and readable logging.

    codeflash/optimization/optimizer.py [98-102]

     start_time = time.time()
     ...
    -logger.info(f"Discovered {num_discovered_tests} existing unit tests in {time.time() - start_time}s at {self.test_cfg.tests_root}")
    +elapsed = time.time() - start_time
    +logger.info(f"Discovered {num_discovered_tests} existing unit tests in {elapsed:.2f}s at {self.test_cfg.tests_root}")
    Suggestion importance[1-10]: 6

    __

    Why: The improvement enhances the readability of the logged elapsed time by formatting it to two decimals, though it only offers a minor usability enhancement.

    Low

    @misrasaurabh1 misrasaurabh1 requested a review from KRRT7 April 16, 2025 22:41
    Copy link
    Contributor

    @KRRT7 KRRT7 left a comment

    Choose a reason for hiding this comment

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

    sure, but FYI: this will be cut down drastically in my next PR due to caching the tests (as part of VSC work)

    @misrasaurabh1 misrasaurabh1 merged commit 1585e4b into main Apr 17, 2025
    15 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants