-
Notifications
You must be signed in to change notification settings - Fork 13
/
CriticalPathModule.java
98 lines (88 loc) · 3.59 KB
/
CriticalPathModule.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*******************************************************************************
* Copyright (c) 2015, 2024 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.tracecompass.internal.analysis.graph.core.criticalpath;
import java.util.Objects;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.analysis.graph.core.base.IGraphWorker;
import org.eclipse.tracecompass.analysis.graph.core.building.AbstractTmfGraphBuilderModule;
import org.eclipse.tracecompass.analysis.graph.core.criticalpath.ICriticalPathProvider;
import org.eclipse.tracecompass.analysis.graph.core.criticalpath.OSCriticalPathModule;
import org.eclipse.tracecompass.internal.analysis.graph.core.base.TmfGraph;
import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
import com.google.common.annotations.VisibleForTesting;
/**
* Class to implement the critical path analysis
*
* @author Francis Giraldeau
* @author Geneviève Bastien
*/
@Deprecated
public class CriticalPathModule extends TmfAbstractAnalysisModule implements ICriticalPathProvider {
/**
* Analysis ID for this module
*/
public static final String ANALYSIS_ID = "org.eclipse.tracecompass.analysis.graph.core.criticalpath"; //$NON-NLS-1$
/** Worker_id parameter name */
private @Nullable OSCriticalPathModule fCriticalPathModule;
private AbstractTmfGraphBuilderModule fGraph;
private @Nullable IGraphWorker fWorker;
/**
* Default constructor
*
* @param graph
* The graph module that will be used to calculate the critical
* path on
* @since 4.0
*/
public CriticalPathModule(AbstractTmfGraphBuilderModule graph) {
fGraph = graph;
}
/**
* Constructor with the parameter. Can be used by benchmarks, to avoid that
* setting the parameter causes the module to be schedule and run in a job
* which keeps it in memory forever (and thus can cause OOME)
*
* @param graph
* The graph module that will be used to calculate the critical
* path on
* @param worker
* The worker parameter to set
* @since 4.0
*/
@VisibleForTesting
public CriticalPathModule(AbstractTmfGraphBuilderModule graph, IGraphWorker worker) {
fGraph = graph;
fWorker = worker;
}
private CriticalPathModule getCriticalPathModule() {
if (fCriticalPathModule == null) {
if (fWorker == null) {
fCriticalPathModule = new OSCriticalPathModule(fGraph);
} else {
fCriticalPathModule = new OSCriticalPathModule(fGraph, Objects.requireNonNull(fWorker));
}
}
return Objects.requireNonNull(fCriticalPathModule);
}
public @Nullable TmfGraph getCriticalPath() {
return getCriticalPathModule().getCriticalPath();
}
@Override
protected boolean executeAnalysis(IProgressMonitor monitor) throws TmfAnalysisException {
return getCriticalPathModule().executeAnalysis(monitor);
}
@Override
protected void canceling() {
getCriticalPathModule().canceling();
}
}