-
Notifications
You must be signed in to change notification settings - Fork 22
fix discovery of replay tests of class methods #355
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
… (`filter_test_files_by_imports_bug_fix`) Here is an optimized version of your program, focusing on the key bottlenecks identified in the profiler. **Major improvements:** - **Use set lookup and precomputed data:** To avoid repeated work in `any(...)` calls, we build sets/maps to batch-check function names needing exact and prefix matching. - **Flatten loop logic:** We reduce string concatenation and duplicate calculation. - **Short-circuit loop on match:** As soon as a match is found, break out of loops ASAP. - **Precompute most-used string to minimize per-iteration computation.** **Summary of changes:** - We pre-group full match and dotted-prefix match targets. - We remove two `any()` generator expressions over a set in favor of direct set lookups and for-loops over a prefiltered small candidate list. - All string concatenations and attribute accesses are done at most once per iteration. - Early returns are used to short-circuit unnecessary further work. This should be **significantly faster**, especially when the set of names is large and there are many aliases per import.
⚡️ Codeflash found optimizations for this PR📄 240% (2.40x) speedup for
|
…25-06-20T22.22.32 ⚡️ Speed up method `ImportAnalyzer.visit_ImportFrom` by 240% in PR #355 (`filter_test_files_by_imports_bug_fix`)
|
This PR is now faster! 🚀 @KRRT7 accepted my optimizations from: |
PR Type
Bug fix, Tests, Enhancement
Description
Refactor import discovery logic for nested and aliased functions
Increase expected traced count in end-to-end tests
Add AlexNet and SimpleModel classes with forward/predict
Introduce test_models function and call under main
Changes walkthrough 📝
workload.py
Add demo model classes and testscode_to_optimize/code_directories/simple_tracer_e2e/workload.py
AlexNetmodel class with init, forward, extract, classifySimpleModelclass withpredictandcreate_defaulttest_modelsfunction using new model classestest_modelsunder the__main__guardend_to_end_test_utilities.py
Update expected traced functions counttests/scripts/end_to_end_test_utilities.py
discover_unit_tests.py
Refactor import function discovery logiccodeflash/discovery/discover_unit_tests.py
found_any_target_functionandfound_qualified_name