當前位置: 首頁>>代碼示例>>Java>>正文


Java Profiler類代碼示例

本文整理匯總了Java中edu.umd.cs.findbugs.log.Profiler的典型用法代碼示例。如果您正苦於以下問題:Java Profiler類的具體用法?Java Profiler怎麽用?Java Profiler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Profiler類屬於edu.umd.cs.findbugs.log包,在下文中一共展示了Profiler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: analyzeMethod

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
/**
 * Analyze a method.
 *
 * @param classContext
 *            ClassContext storing method analysis objects for method's
 *            class
 * @param analysisClass
 *            class the method analysis object should belong to
 * @param methodDescriptor
 *            method descriptor identifying the method to analyze
 * @return the computed analysis object for the method
 * @throws CheckedAnalysisException
 */
@SuppressWarnings("unchecked")
private <E> E analyzeMethod(ClassContext classContext, Class<E> analysisClass, MethodDescriptor methodDescriptor)
        throws CheckedAnalysisException {
    IMethodAnalysisEngine<E> engine = (IMethodAnalysisEngine<E>) methodAnalysisEngineMap.get(analysisClass);
    if (engine == null) {
        throw new IllegalArgumentException("No analysis engine registered to produce " + analysisClass.getName());
    }
    Profiler profiler = getProfiler();
    profiler.start(engine.getClass());
    try {
        return engine.analyze(this, methodDescriptor);
    } finally {
        profiler.end(engine.getClass());
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:29,代碼來源:AnalysisCache.java

示例2: validate

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public When validate(Object constantValue) {
    if (validator == null)
        throw new IllegalStateException("No validator");
    IAnalysisCache analysisCache = Global.getAnalysisCache();
    Profiler profiler = analysisCache.getProfiler();
    profiler.start(validator.getClass());
    AtomicBoolean performing = performingValidation.get();
    try {
        if (!performing.compareAndSet(false, true)) {
            throw new IllegalStateException("recursive validation");
        }

        return validator.forConstantValue(proxy, constantValue);
    } catch (Exception e) {
        AnalysisContext.logError("Error executing custom validator for " + typeQualifier + " " + constantValue, e);
        return When.UNKNOWN;
    } finally {
        if (!performing.compareAndSet(true, false)) {
            throw new IllegalStateException("performingValidation not set when validation completes");
        }
        profiler.end(validator.getClass());

    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:25,代碼來源:TypeQualifierValue.java

示例3: analyzeMethod

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public void analyzeMethod(ClassContext classContext, Method method, ResourceTrackerType resourceTracker,
        ResourceCollection<Resource> resourceCollection) throws CFGBuilderException, DataflowAnalysisException {

    MethodGen methodGen = classContext.getMethodGen(method);
    if (methodGen == null)
        return;
    try {
        CFG cfg = classContext.getCFG(method);
        DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);

        if (DEBUG)
            System.out.println(SignatureConverter.convertMethodSignature(methodGen));

        for (Iterator<Resource> i = resourceCollection.resourceIterator(); i.hasNext();) {
            Resource resource = i.next();

            ResourceValueAnalysis<Resource> analysis = new ResourceValueAnalysis<Resource>(methodGen, cfg, dfs,
                    resourceTracker, resource);
            Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>> dataflow = new Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>>(
                    cfg, analysis);

            Profiler profiler = Global.getAnalysisCache().getProfiler();
            profiler.start(resourceTracker.getClass());
            try {
                dataflow.execute();
            } finally {
                profiler.end(resourceTracker.getClass());
            }
            inspectResult(classContext, methodGen, cfg, dataflow, resource);
        }
    } catch (RuntimeException e) {
        AnalysisContext.logError("Exception while analyzing " + methodGen.getClassName() + "." + methodGen.getName() + ":"
                + methodGen.getSignature(), e);
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:36,代碼來源:ResourceTrackingDetector.java

示例4: analyze

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public ObligationDataflow analyze(IAnalysisCache analysisCache, MethodDescriptor methodDescriptor)
        throws CheckedAnalysisException {
    CFG cfg = analysisCache.getMethodAnalysis(CFG.class, methodDescriptor);
    DepthFirstSearch dfs = analysisCache.getMethodAnalysis(DepthFirstSearch.class, methodDescriptor);
    XMethod xmethod = XFactory.createXMethod(methodDescriptor);
    ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, methodDescriptor.getClassDescriptor());

    ObligationPolicyDatabase database = analysisCache.getDatabase(ObligationPolicyDatabase.class);

    TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, methodDescriptor);
    IsNullValueDataflow invDataflow = analysisCache.getMethodAnalysis(IsNullValueDataflow.class, methodDescriptor);

    ObligationFactory factory = database.getFactory();

    ObligationAnalysis analysis = new ObligationAnalysis(dfs, xmethod, cpg, factory, database, typeDataflow, invDataflow,
            analysisCache.getErrorLogger());
    ObligationDataflow dataflow = new ObligationDataflow(cfg, analysis);

    Profiler profiler = analysisCache.getProfiler();
    profiler.start(analysis.getClass());
    try {
        dataflow.execute();
    } finally {
        profiler.end(analysis.getClass());
    }

    if (DEBUG_PRINTCFG) {
        System.out.println("Dataflow CFG:");
        DataflowCFGPrinter.printCFG(dataflow, System.out);
    }

    return dataflow;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:34,代碼來源:ObligationDataflowFactory.java

示例5: makeZipCodeBase

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public static AbstractScannableCodeBase makeZipCodeBase(ICodeBaseLocator codeBaseLocator, File file) throws IOException {
    Profiler profiler = Global.getAnalysisCache().getProfiler();
    profiler.start(ZipCodeBaseFactory.class);
    try {
        return countUsingZipFile(codeBaseLocator, file);
    } finally {
        profiler.end(ZipCodeBaseFactory.class);
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:10,代碼來源:ZipCodeBaseFactory.java

示例6: visitClass

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {

        // Just get the ClassContext from the analysis cache
        // and apply the detector to it.

        IAnalysisCache analysisCache = Global.getAnalysisCache();
        ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, classDescriptor);
        Profiler profiler = analysisCache.getProfiler();
        profiler.start(detector.getClass());
        try {
            detector.visitClassContext(classContext);
        } finally {
            profiler.end(detector.getClass());
        }
    }
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:16,代碼來源:DetectorToDetector2Adapter.java

示例7: getResolvedAnnotation

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public NullnessAnnotation getResolvedAnnotation(Object o, boolean getMinimal) {
    Profiler profiler = Global.getAnalysisCache().getProfiler();
    profiler.start(this.getClass());
    try {

        if (DEBUG) {
            System.out.println("getResolvedAnnotation: o=" + o + "...");
        }

        TypeQualifierAnnotation tqa = null;

        if (o instanceof XMethodParameter) {
            XMethodParameter param = (XMethodParameter) o;

            tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(param.getMethod(),
                    param.getParameterNumber(), nonnullTypeQualifierValue);
        } else if (o instanceof XMethod || o instanceof XField) {
            tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation((AnnotatedObject) o,
                    nonnullTypeQualifierValue);
        }

        NullnessAnnotation result = toNullnessAnnotation(tqa);
        if (DEBUG) {
            if (result == null)
                System.out.println("   ===> not found");
            else
                System.out.println("   ===> " + tqa + "/" + result.toString() );
        }
        return result;
    } finally {
        profiler.end(this.getClass());
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:34,代碼來源:TypeQualifierNullnessAnnotationDatabase.java

示例8: ProjectStats

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
/**
 * Constructor. Creates an empty object.
 */
public ProjectStats() {
    this.packageStatsMap = new TreeMap<String, PackageStats>();
    this.totalClasses = 0;
    this.analysisTimestamp = new Date();
    this.baseFootprint = new Footprint();
    this.profiler = new Profiler();
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:11,代碼來源:ProjectStats.java

示例9: sortByCallGraph

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public static <E> List<E> sortByCallGraph(Collection<E> elements, OutEdges<E> outEdges) {
    Profiler profile = Global.getAnalysisCache().getProfiler();
    profile.start(TopologicalSort.class);
    try {
        SortAlgorithm<E> instance = new Worker2<E>(elements, outEdges);
        return instance.compute();
    } finally {
        profile.end(TopologicalSort.class);
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:11,代碼來源:TopologicalSort.java

示例10: makeZipCodeBase

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public static AbstractScannableCodeBase makeZipCodeBase(ICodeBaseLocator codeBaseLocator, File file) throws IOException {
    Profiler profiler = Global.getAnalysisCache().getProfiler();
    profiler.start(ZipCodeBaseFactory.class);
    try {
        return new ZipFileCodeBase(codeBaseLocator, file);
    } catch (ZipException e) {
       // May be too many zip entries
       return new ZipInputStreamCodeBase(codeBaseLocator, file);
    } finally {
        profiler.end(ZipCodeBaseFactory.class);
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:13,代碼來源:ZipCodeBaseFactory.java

示例11: validate

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public When validate(@CheckForNull Object constantValue) {
    if (validator == null)
        throw new IllegalStateException("No validator");
    IAnalysisCache analysisCache = Global.getAnalysisCache();
    Profiler profiler = analysisCache.getProfiler();
    profiler.start(validator.getClass());
    try {
        return ValidationSecurityManager.sandboxedValidation(proxy, validator, constantValue);
    } catch (Exception e) {
        AnalysisContext.logError("Error executing custom validator for " + typeQualifier + " " + constantValue, e);
        return When.UNKNOWN;
    } finally {
        profiler.end(validator.getClass());
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:16,代碼來源:TypeQualifierValue.java

示例12: getInheritedAnnotation

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public @CheckForNull NullnessAnnotation getInheritedAnnotation(XMethod m, int parameter) {
    Profiler profiler = Global.getAnalysisCache().getProfiler();
    profiler.start(this.getClass());
    try {
        TypeQualifierAnnotation tqa
        = TypeQualifierApplications.getInheritedTypeQualifierAnnotation(m,
               parameter, nonnullTypeQualifierValue);
        NullnessAnnotation result = toNullnessAnnotation(tqa);
        return result;
    } finally {
        profiler.end(this.getClass());
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:14,代碼來源:TypeQualifierNullnessAnnotationDatabase.java

示例13: getDirectAnnotation

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public @CheckForNull NullnessAnnotation getDirectAnnotation(Object o) {
    Profiler profiler = Global.getAnalysisCache().getProfiler();
    profiler.start(this.getClass());
    try {

        if (DEBUG) {
            System.out.println("getDirectAnnotation: o=" + o + "...");
        }

        TypeQualifierAnnotation tqa = null;

        if (o instanceof XMethodParameter) {
            XMethodParameter param = (XMethodParameter) o;
            tqa = TypeQualifierApplications.getDirectTypeQualifierAnnotation(param.getMethod(),
                    param.getParameterNumber(), nonnullTypeQualifierValue);
        } else if (o instanceof XMethod || o instanceof XField) {
            tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation((AnnotatedObject) o,
                    nonnullTypeQualifierValue);
        }

        NullnessAnnotation result = toNullnessAnnotation(tqa);
        if (DEBUG) {
            if (result == null)
                System.out.println("   ===> not found");
            else
                System.out.println("   ===> " + tqa + "/" + result.toString() );
        }
        return result;
    } finally {
        profiler.end(this.getClass());
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:33,代碼來源:TypeQualifierNullnessAnnotationDatabase.java

示例14: reportResultsToConsole

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
/**
 * If there is a FB console opened, report results and statistics to it.
 */
private void reportResultsToConsole() {
    if (!isStreamReportingEnabled()) {
        return;
    }
    printToStream("Finished, found: " + bugCount + " bugs");
    ConfigurableXmlOutputStream xmlStream = new ConfigurableXmlOutputStream(stream, true);
    ProjectStats stats = bugCollection.getProjectStats();

    printToStream("\nFootprint: " + new Footprint(stats.getBaseFootprint()).toString());

    Profiler profiler = stats.getProfiler();
    PrintStream printStream;
    try {
        printStream = new PrintStream(stream, false, "UTF-8");
    } catch (UnsupportedEncodingException e1) {
        // can never happen with UTF-8
        return;
    }

    printToStream("\nTotal time:");
    profiler.report(new Profiler.TotalTimeComparator(profiler), new Profiler.FilterByTime(10000000), printStream);

    printToStream("\nTotal calls:");
    int numClasses = stats.getNumClasses();
    if(numClasses > 0) {
        profiler.report(new Profiler.TotalCallsComparator(profiler), new Profiler.FilterByCalls(numClasses),
                printStream);

        printToStream("\nTime per call:");
        profiler.report(new Profiler.TimePerCallComparator(profiler),
                new Profiler.FilterByTimePerCall(10000000 / numClasses), printStream);
    }
    try {
        xmlStream.finish();
    } catch (IOException e) {
        FindbugsPlugin.getDefault().logException(e, "Print to console failed");
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:42,代碼來源:Reporter.java

示例15: getProfiler

import edu.umd.cs.findbugs.log.Profiler; //導入依賴的package包/類
public Profiler getProfiler() {
    return bugReporter.getProjectStats().getProfiler();
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:4,代碼來源:AnalysisCache.java


注:本文中的edu.umd.cs.findbugs.log.Profiler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。