Skip to content

Commit ff53872

Browse files
committed
Exclude time from entry points and IR.
1 parent d584ae2 commit ff53872

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/analysis/StreamAnalyzer.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.HashSet;
1212
import java.util.Iterator;
1313
import java.util.Map;
14+
import java.util.Optional;
1415
import java.util.Scanner;
1516
import java.util.Set;
1617
import java.util.logging.Level;
@@ -41,6 +42,7 @@
4142
import com.ibm.wala.util.scope.JUnitEntryPoints;
4243

4344
import edu.cuny.hunter.streamrefactoring.core.utils.LoggerNames;
45+
import edu.cuny.hunter.streamrefactoring.core.utils.TimeCollector;
4446
import edu.cuny.hunter.streamrefactoring.core.wala.EclipseProjectAnalysisEngine;
4547

4648
@SuppressWarnings("restriction")
@@ -93,10 +95,23 @@ public StreamAnalyzer(boolean visitDocTags, boolean findImplicitEntryPoints, boo
9395

9496
/**
9597
* 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).
98101
*/
99102
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 {
100115
Map<IJavaProject, Collection<Entrypoint>> ret = new HashMap<>();
101116

102117
// collect the projects to be analyzed.
@@ -106,6 +121,9 @@ public Map<IJavaProject, Collection<Entrypoint>> analyze() throws CoreException
106121
// process each project.
107122
for (IJavaProject project : projectToStreams.keySet()) {
108123
// 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);
109127
EclipseProjectAnalysisEngine<InstanceKey> engine = null;
110128
try {
111129
engine = new EclipseProjectAnalysisEngine<>(project);
@@ -114,11 +132,12 @@ public Map<IJavaProject, Collection<Entrypoint>> analyze() throws CoreException
114132
LOGGER.log(Level.SEVERE, "Could not create analysis engine for: " + project.getElementName(), e);
115133
throw new RuntimeException(e);
116134
}
135+
collector.ifPresent(TimeCollector::stop);
117136

118137
// build the call graph for the project.
119138
Collection<Entrypoint> entryPoints = null;
120139
try {
121-
entryPoints = this.buildCallGraph(engine);
140+
entryPoints = this.buildCallGraph(engine, collector);
122141
} catch (IOException | CoreException | CancelException e) {
123142
LOGGER.log(Level.SEVERE,
124143
"Exception encountered while building call graph for: " + project.getElementName() + ".", e);
@@ -187,12 +206,17 @@ public Map<IJavaProject, Collection<Entrypoint>> analyze() throws CoreException
187206
* @param engine
188207
* The EclipseProjectAnalysisEngine for which to build the call
189208
* graph.
209+
* @param collector
210+
* A {@link TimeCollector} to exclude entry point finding.
190211
* @return The {@link Entrypoint}s used in building the {@link CallGraph}.
191212
*/
192-
protected Collection<Entrypoint> buildCallGraph(EclipseProjectAnalysisEngine<InstanceKey> engine)
213+
protected Collection<Entrypoint> buildCallGraph(EclipseProjectAnalysisEngine<InstanceKey> engine,
214+
Optional<TimeCollector> collector)
193215
throws IOException, CoreException, CallGraphBuilderCancelException, CancelException {
194216
// if we haven't built the call graph yet.
195217
if (!this.enginesWithBuiltCallGraphsToEntrypointsUsed.keySet().contains(engine)) {
218+
// find entry points (but exclude it from the time).
219+
collector.ifPresent(TimeCollector::start);
196220
Set<Entrypoint> entryPoints;
197221

198222
// find the entry_points.txt in the project directory
@@ -241,6 +265,8 @@ protected Collection<Entrypoint> buildCallGraph(EclipseProjectAnalysisEngine<Ins
241265
return entryPoints;
242266
}
243267

268+
collector.ifPresent(TimeCollector::stop);
269+
244270
// set options.
245271
AnalysisOptions options = engine.getDefaultOptions(entryPoints);
246272
// Turn off reflection analysis.

edu.cuny.hunter.streamrefactoring.core/src/edu/cuny/hunter/streamrefactoring/core/refactorings/ConvertToParallelStreamRefactoringProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor, fi
217217
}
218218

219219
// analyze and set entry points.
220-
this.projectToEntryPoints = analyzer.analyze();
220+
this.projectToEntryPoints = analyzer.analyze(Optional.of(this.getExcludedTimeCollector()));
221221

222222
// map empty set to unprocessed projects.
223223
for (IJavaProject project : this.getJavaProjects())

0 commit comments

Comments
 (0)