11
11
import java .util .HashSet ;
12
12
import java .util .Iterator ;
13
13
import java .util .Map ;
14
+ import java .util .Optional ;
14
15
import java .util .Scanner ;
15
16
import java .util .Set ;
16
17
import java .util .logging .Level ;
41
42
import com .ibm .wala .util .scope .JUnitEntryPoints ;
42
43
43
44
import edu .cuny .hunter .streamrefactoring .core .utils .LoggerNames ;
45
+ import edu .cuny .hunter .streamrefactoring .core .utils .TimeCollector ;
44
46
import edu .cuny .hunter .streamrefactoring .core .wala .EclipseProjectAnalysisEngine ;
45
47
46
48
@ SuppressWarnings ("restriction" )
@@ -93,10 +95,23 @@ public StreamAnalyzer(boolean visitDocTags, boolean findImplicitEntryPoints, boo
93
95
94
96
/**
95
97
* Analyzes this {@link StreamAnalyzer}'s streams.
96
- *
97
- * @return {@link Map} of project's analyzed along with the entry points used.
98
+ *
99
+ * @return A {@link Map} of project's analyzed along with the entry points used.
100
+ * @see #analyze(Optional).
98
101
*/
99
102
public Map <IJavaProject , Collection <Entrypoint >> analyze () throws CoreException {
103
+ return this .analyze (Optional .empty ());
104
+ }
105
+
106
+ /**
107
+ * Analyzes this {@link StreamAnalyzer}'s streams.
108
+ *
109
+ * @param collector
110
+ * To exclude from the time certain parts of the analysis.
111
+ * @return A {@link Map} of project's analyzed along with the entry points used.
112
+ * @see #analyze().
113
+ */
114
+ public Map <IJavaProject , Collection <Entrypoint >> analyze (Optional <TimeCollector > collector ) throws CoreException {
100
115
Map <IJavaProject , Collection <Entrypoint >> ret = new HashMap <>();
101
116
102
117
// collect the projects to be analyzed.
@@ -106,6 +121,9 @@ public Map<IJavaProject, Collection<Entrypoint>> analyze() throws CoreException
106
121
// process each project.
107
122
for (IJavaProject project : projectToStreams .keySet ()) {
108
123
// create the analysis engine for the project.
124
+ // exclude from the analysis because the IR will be built here.
125
+
126
+ collector .ifPresent (TimeCollector ::start );
109
127
EclipseProjectAnalysisEngine <InstanceKey > engine = null ;
110
128
try {
111
129
engine = new EclipseProjectAnalysisEngine <>(project );
@@ -114,11 +132,12 @@ public Map<IJavaProject, Collection<Entrypoint>> analyze() throws CoreException
114
132
LOGGER .log (Level .SEVERE , "Could not create analysis engine for: " + project .getElementName (), e );
115
133
throw new RuntimeException (e );
116
134
}
135
+ collector .ifPresent (TimeCollector ::stop );
117
136
118
137
// build the call graph for the project.
119
138
Collection <Entrypoint > entryPoints = null ;
120
139
try {
121
- entryPoints = this .buildCallGraph (engine );
140
+ entryPoints = this .buildCallGraph (engine , collector );
122
141
} catch (IOException | CoreException | CancelException e ) {
123
142
LOGGER .log (Level .SEVERE ,
124
143
"Exception encountered while building call graph for: " + project .getElementName () + "." , e );
@@ -187,12 +206,17 @@ public Map<IJavaProject, Collection<Entrypoint>> analyze() throws CoreException
187
206
* @param engine
188
207
* The EclipseProjectAnalysisEngine for which to build the call
189
208
* graph.
209
+ * @param collector
210
+ * A {@link TimeCollector} to exclude entry point finding.
190
211
* @return The {@link Entrypoint}s used in building the {@link CallGraph}.
191
212
*/
192
- protected Collection <Entrypoint > buildCallGraph (EclipseProjectAnalysisEngine <InstanceKey > engine )
213
+ protected Collection <Entrypoint > buildCallGraph (EclipseProjectAnalysisEngine <InstanceKey > engine ,
214
+ Optional <TimeCollector > collector )
193
215
throws IOException , CoreException , CallGraphBuilderCancelException , CancelException {
194
216
// if we haven't built the call graph yet.
195
217
if (!this .enginesWithBuiltCallGraphsToEntrypointsUsed .keySet ().contains (engine )) {
218
+ // find entry points (but exclude it from the time).
219
+ collector .ifPresent (TimeCollector ::start );
196
220
Set <Entrypoint > entryPoints ;
197
221
198
222
// find the entry_points.txt in the project directory
@@ -241,6 +265,8 @@ protected Collection<Entrypoint> buildCallGraph(EclipseProjectAnalysisEngine<Ins
241
265
return entryPoints ;
242
266
}
243
267
268
+ collector .ifPresent (TimeCollector ::stop );
269
+
244
270
// set options.
245
271
AnalysisOptions options = engine .getDefaultOptions (entryPoints );
246
272
// Turn off reflection analysis.
0 commit comments