Commit 5f7cbbd
committed
refactor(tests): speed up unused metrics check with single grep
Replace per-field grep in test_unused_metrics (one subprocess per metric
field, ~208 invocations) with a single grep that matches all field names
at once and filters results in Python.
Changes in fcmetrics.py:
- Remove is_metric_used() which ran grep -RPzo per field
- Add find_unused_metrics() which builds a combined alternation of all
field names and runs a single grep -rPn across src/
- Filter grep output in Python to skip test files and metrics definition
files (via renamed is_file_test_or_definition), comment lines, and
string literals
- Rename is_file_production to is_file_test_or_definition to reflect
what it actually checks
Changes in test_rust.py:
- Simplify test_unused_metrics to call find_unused_metrics() directly
- Remove unused imports (defaultdict, extract_fields,
find_metrics_files, is_metric_used)
Signed-off-by: Riccardo Mancini <mancio@amazon.com>1 parent 0f72a01 commit 5f7cbbd
2 files changed
Lines changed: 58 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
633 | | - | |
634 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
635 | 637 | | |
636 | 638 | | |
637 | 639 | | |
| |||
652 | 654 | | |
653 | 655 | | |
654 | 656 | | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
| 657 | + | |
| 658 | + | |
659 | 659 | | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
666 | 680 | | |
667 | | - | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
668 | 685 | | |
669 | | - | |
| 686 | + | |
| 687 | + | |
670 | 688 | | |
671 | 689 | | |
672 | | - | |
673 | | - | |
674 | | - | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
8 | | - | |
| 6 | + | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
| |||
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 30 | + | |
45 | 31 | | |
46 | | - | |
47 | 32 | | |
48 | 33 | | |
49 | 34 | | |
| |||
0 commit comments