mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Related to 155324, output statistics when tracing indexer.
This commit is contained in:
parent
52522d53bf
commit
6f3df88cd1
5 changed files with 65 additions and 38 deletions
|
@ -27,6 +27,8 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
|
@ -54,16 +56,27 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
protected volatile int fTotalSourcesEstimate= 0;
|
protected volatile int fTotalSourcesEstimate= 0;
|
||||||
protected volatile int fCompletedSources= 0;
|
protected volatile int fCompletedSources= 0;
|
||||||
protected volatile int fCompletedHeaders= 0;
|
protected volatile int fCompletedHeaders= 0;
|
||||||
protected int fErrorCount;
|
|
||||||
protected Map fContextMap= new HashMap();
|
protected Map fContextMap= new HashMap();
|
||||||
protected volatile String fMessage;
|
protected volatile String fMessage;
|
||||||
protected boolean fTrace;
|
|
||||||
|
private boolean fTrace;
|
||||||
|
private boolean fShowStatistics;
|
||||||
|
private int fResolutionTime;
|
||||||
|
private int fParsingTime;
|
||||||
|
private int fAddToIndexTime;
|
||||||
|
private int fErrorCount;
|
||||||
|
private int fReferenceCount= 0;
|
||||||
|
private int fDeclarationCount= 0;
|
||||||
|
private int fProblemBindingCount= 0;
|
||||||
|
|
||||||
protected PDOMIndexerTask() {
|
protected PDOMIndexerTask() {
|
||||||
String trace = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/indexer"); //$NON-NLS-1$
|
fTrace= checkDebugOption("indexer", "true"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
if (trace != null && trace.equalsIgnoreCase("true")) { //$NON-NLS-1$
|
fShowStatistics= checkDebugOption("pdomtimings", "true"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
fTrace= true;
|
}
|
||||||
}
|
|
||||||
|
private boolean checkDebugOption(String option, String value) {
|
||||||
|
String trace = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/" + option); //$NON-NLS-1$
|
||||||
|
return (trace != null && trace.equalsIgnoreCase(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processDelta(ICElementDelta delta, Collection added, Collection changed, Collection removed) throws CoreException {
|
protected void processDelta(ICElementDelta delta, Collection added, Collection changed, Collection removed) throws CoreException {
|
||||||
|
@ -190,7 +203,9 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
fMessage= MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
fMessage= MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
||||||
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()});
|
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()});
|
||||||
|
long start= System.currentTimeMillis();
|
||||||
doParseTU(tu, pm);
|
doParseTU(tu, pm);
|
||||||
|
fParsingTime += System.currentTimeMillis()-start;
|
||||||
}
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
swallowError(path, e);
|
swallowError(path, e);
|
||||||
|
@ -304,16 +319,28 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
ArrayList[] arrayLists = ((ArrayList[]) symbolMap.get(path));
|
ArrayList[] arrayLists = ((ArrayList[]) symbolMap.get(path));
|
||||||
|
|
||||||
// resolve the names
|
// resolve the names
|
||||||
|
long start= System.currentTimeMillis();
|
||||||
ArrayList names= arrayLists[2];
|
ArrayList names= arrayLists[2];
|
||||||
for (int j=0; j<names.size(); j++) {
|
for (int j=0; j<names.size(); j++) {
|
||||||
((IASTName[]) names.get(j))[0].resolveBinding();
|
final IASTName name = ((IASTName[]) names.get(j))[0];
|
||||||
|
final IBinding binding= name.resolveBinding();
|
||||||
|
if (fShowStatistics) {
|
||||||
|
if (binding instanceof IProblemBinding)
|
||||||
|
fProblemBindingCount++;
|
||||||
|
else if (name.isReference())
|
||||||
|
fReferenceCount++;
|
||||||
|
else
|
||||||
|
fDeclarationCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fResolutionTime += System.currentTimeMillis()-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isFirstRequest= true;
|
boolean isFirstRequest= true;
|
||||||
boolean isFirstAddition= true;
|
boolean isFirstAddition= true;
|
||||||
IWritableIndex index= getIndex();
|
IWritableIndex index= getIndex();
|
||||||
index.acquireWriteLock(getReadlockCount());
|
index.acquireWriteLock(getReadlockCount());
|
||||||
|
long start= System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
for (int i=0; i<orderedPaths.length; i++) {
|
for (int i=0; i<orderedPaths.length; i++) {
|
||||||
if (pm.isCanceled())
|
if (pm.isCanceled())
|
||||||
|
@ -340,6 +367,7 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
} finally {
|
} finally {
|
||||||
index.releaseWriteLock(getReadlockCount());
|
index.releaseWriteLock(getReadlockCount());
|
||||||
}
|
}
|
||||||
|
fAddToIndexTime+= System.currentTimeMillis()-start;
|
||||||
fCompletedSources++;
|
fCompletedSources++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,4 +473,26 @@ public abstract class PDOMIndexerTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void traceEnd(long start) {
|
||||||
|
if (fShowStatistics) {
|
||||||
|
String name= getClass().getName();
|
||||||
|
name= name.substring(name.lastIndexOf('.')+1);
|
||||||
|
|
||||||
|
System.out.println(name + " " + getIndexer().getProject().getElementName() //$NON-NLS-1$
|
||||||
|
+ " (" + fCompletedSources + " sources, " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
+ fCompletedHeaders + " headers)"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
System.out.println(name + " Timings: " //$NON-NLS-1$
|
||||||
|
+ (System.currentTimeMillis() - start) + " total, " //$NON-NLS-1$
|
||||||
|
+ fParsingTime + " parser, " //$NON-NLS-1$
|
||||||
|
+ fResolutionTime + " resolution, " //$NON-NLS-1$
|
||||||
|
+ fAddToIndexTime + " index update."); //$NON-NLS-1$
|
||||||
|
System.out.println(name + " Result: " //$NON-NLS-1$
|
||||||
|
+ fDeclarationCount + " declarations, " //$NON-NLS-1$
|
||||||
|
+ fReferenceCount + " references, " //$NON-NLS-1$
|
||||||
|
+ fErrorCount + " errors, " //$NON-NLS-1$
|
||||||
|
+ fProblemBindingCount + " problems."); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
|
|
||||||
class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
|
|
||||||
|
@ -35,9 +34,8 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
setupIndexAndReaderFactory();
|
setupIndexAndReaderFactory();
|
||||||
registerTUsInReaderFactory(changed);
|
registerTUsInReaderFactory(changed);
|
||||||
|
|
||||||
|
@ -71,14 +69,10 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/pdomtimings"); //$NON-NLS-1$
|
|
||||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
|
||||||
System.out.println("PDOM Fast Delta Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
|
||||||
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
traceEnd(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -30,8 +29,8 @@ class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(final IProgressMonitor monitor) {
|
public void run(final IProgressMonitor monitor) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
boolean allFiles= getIndexAllFiles();
|
boolean allFiles= getIndexAllFiles();
|
||||||
List sources= new ArrayList();
|
List sources= new ArrayList();
|
||||||
List headers= new ArrayList();
|
List headers= new ArrayList();
|
||||||
|
@ -49,15 +48,10 @@ class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
registerTUsInReaderFactory(headers);
|
registerTUsInReaderFactory(headers);
|
||||||
parseTUs(sources, headers, monitor);
|
parseTUs(sources, headers, monitor);
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
|
||||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
|
||||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
|
||||||
System.out.println("PDOM Fast Reindex Time: " + (System.currentTimeMillis() - start) //$NON-NLS-1$
|
|
||||||
+ " " + indexer.getProject().getElementName()); //$NON-NLS-1$
|
|
||||||
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
traceEnd(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -39,8 +38,8 @@ class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
setupIndexAndReaderFactory();
|
setupIndexAndReaderFactory();
|
||||||
|
|
||||||
// separate headers
|
// separate headers
|
||||||
|
@ -73,14 +72,10 @@ class PDOMFullHandleDelta extends PDOMFullIndexerJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
parseTUs(sources, headers, monitor);
|
parseTUs(sources, headers, monitor);
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
|
||||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
|
||||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
|
||||||
System.out.println("PDOM Full Delta Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
traceEnd(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,8 +31,8 @@ class PDOMFullReindex extends PDOMFullIndexerJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(final IProgressMonitor monitor) {
|
public void run(final IProgressMonitor monitor) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
boolean allFiles= getIndexAllFiles();
|
boolean allFiles= getIndexAllFiles();
|
||||||
List sources= new ArrayList();
|
List sources= new ArrayList();
|
||||||
List headers= new ArrayList();
|
List headers= new ArrayList();
|
||||||
|
@ -50,16 +49,11 @@ class PDOMFullReindex extends PDOMFullIndexerJob {
|
||||||
|
|
||||||
registerTUsInReaderFactory(sources);
|
registerTUsInReaderFactory(sources);
|
||||||
parseTUs(sources, headers, monitor);
|
parseTUs(sources, headers, monitor);
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
|
||||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
|
||||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
|
||||||
System.out.println(indexer.getID()+" indexing time: " + (System.currentTimeMillis() - start) //$NON-NLS-1$
|
|
||||||
+ " " + indexer.getProject().getElementName()); //$NON-NLS-1$
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
if (e.getStatus() != Status.CANCEL_STATUS)
|
if (e.getStatus() != Status.CANCEL_STATUS)
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
|
traceEnd(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue