Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.selesse.jxlint.settings;
 
 
 import java.util.Map;
public class Profiler {
    private static Profiler instance = new Profiler();
    private Stopwatch stopwatch;
    private boolean isEnabled;
    private Map<LintRuleLongruleExecutionTimeMap;
    private Profiler() {
         = new TreeMap<LintRuleLong>(new Comparator<LintRule>() {
            @Override
            public int compare(LintRule lintRuleLintRule lintRule2) {
                return lintRule.getName().compareToIgnoreCase(lintRule2.getName());
            }
        });
    }
    public static void beginProgramProfiling() {
        . = Stopwatch.createStarted();
    }
    public static void endProgramProfiling() {
        . = ..stop();
    }
    public static boolean isEnabled() {
        return .;
    }
    public static void setEnabled(boolean isEnabled) {
        . = isEnabled;
    }
    public static void addExecutionTime(LintRule lintRulelong executionTimeMs) {
        ..put(lintRuleexecutionTimeMs);
    }
    private static String getJxlintRuntimeReportString() {
        return String.format("Program completed in %3.3f seconds.",
                (..elapsed(.)) / 1000.0);
    }
    private static String getRuleReportString() {
        StringBuilder ruleReport = new StringBuilder();
        boolean shouldPrintBold = false;
        for (Map.Entry<LintRuleLonglintRuleAndLongEntry : ..entrySet()) {
            LintRule lintRule = lintRuleAndLongEntry.getKey();
            long executionTimeMs = lintRuleAndLongEntry.getValue();
            String ruleReportString =
                    String.format("%-40s %3.3f seconds"lintRule.getName(), executionTimeMs / 1000.0);
            if (shouldPrintBold) {
                ruleReportString = ..wrapAround(ruleReportString);
            }
            ruleReport.append(ruleReportString).append("\n");
            shouldPrintBold = !shouldPrintBold;
        }
        return ruleReport.toString();
    }
    public static String getGeneratedProfileReport() {
        String profileReport = "\n\n" + getJxlintRuntimeReportString();
        String ruleReportString = getRuleReportString();
        if (ruleReportString.trim().length() > 0) {
            profileReport += "\n\n" + getRuleReportString();
        }
        return profileReport;
    }
    public static void printProfileReport() {
    }
New to GrepCode? Check out our FAQ X