File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
main/java/org/openrewrite
test/java/org/openrewrite/table Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,7 @@ public LSS editSources(LSS sourceSet) {
181
181
return null ;
182
182
}
183
183
184
+ recipeRunStats .recordSourceVisited (source );
184
185
SourceFile after = source ;
185
186
186
187
try {
Original file line number Diff line number Diff line change 35
35
36
36
public class RecipeRunStats extends DataTable <RecipeRunStats .Row > {
37
37
private final MeterRegistry registry = new SimpleMeterRegistry ();
38
+ private final Set <Path > sourceFileVisited = new HashSet <>();
38
39
private final Set <Path > sourceFileChanged = new HashSet <>();
39
40
40
41
public RecipeRunStats (Recipe recipe ) {
@@ -43,6 +44,10 @@ public RecipeRunStats(Recipe recipe) {
43
44
"Statistics used in analyzing the performance of recipes." );
44
45
}
45
46
47
+ public void recordSourceVisited (SourceFile source ) {
48
+ sourceFileVisited .add (source .getSourcePath ());
49
+ }
50
+
46
51
public void recordSourceFileChanged (@ Nullable SourceFile before , @ Nullable SourceFile after ) {
47
52
if (after != null ) {
48
53
sourceFileChanged .add (after .getSourcePath ());
@@ -73,7 +78,7 @@ public void flush(ExecutionContext ctx) {
73
78
Timer scanner = registry .find ("rewrite.recipe.scan" ).tag ("name" , recipeName ).timer ();
74
79
Row row = new Row (
75
80
recipeName ,
76
- Long . valueOf ( editor . count ()). intValue (),
81
+ sourceFileVisited . size (),
77
82
sourceFileChanged .size (),
78
83
scanner == null ? 0 : (long ) scanner .totalTime (TimeUnit .NANOSECONDS ),
79
84
scanner == null ? 0 : scanner .takeSnapshot ().percentileValues ()[0 ].value (TimeUnit .NANOSECONDS ),
Original file line number Diff line number Diff line change @@ -78,9 +78,7 @@ void singleRow() {
78
78
RecipeRunStats .Row row = rows .get (0 );
79
79
assertThat (row .getRecipe ()).endsWith ("RecipeWithApplicabilityTest" );
80
80
assertThat (row .getSourceFiles ())
81
- .as ("Test framework will invoke the recipe once when it is expected to make a change, " +
82
- "then once again when it is expected to make no change" )
83
- .isEqualTo (2 );
81
+ .isEqualTo (1 );
84
82
assertThat (row .getEditMaxNs ()).isGreaterThan (0 );
85
83
assertThat (row .getEditTotalTimeNs ())
86
84
.as ("Cumulative time should be greater than any single visit time" )
@@ -112,11 +110,11 @@ void sourceFilesCountStatsForSameRecipe() {
112
110
.hasSize (2 );
113
111
for (RecipeRunStats .Row row : rows ) {
114
112
assertThat (row .getSourceFiles ())
115
- .as ("If the same recipe runs with different parameters it shouldn't increment source files count" )
116
- .isEqualTo (2 );
113
+ .as ("If the same recipe runs with different parameters it shouldn't increment several times source files count" )
114
+ .isEqualTo (1 );
117
115
}
118
116
}).expectedCyclesThatMakeChanges (2 ),
119
117
text ("sem" , "sam2" )
120
118
);
121
119
}
122
- }
120
+ }
You can’t perform that action at this time.
0 commit comments