| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.plugins.profiler; |
| | | |
| | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | |
| | | /** |
| | |
| | | public class ProfileStackFrame |
| | | implements Comparable |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.plugins.profiler.ProfilerThread"; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | public ProfileStackFrame(String className, String methodName) |
| | | { |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(className), |
| | | String.valueOf(methodName)); |
| | | |
| | | this.className = className; |
| | | this.methodName = methodName; |
| | |
| | | */ |
| | | public String getClassName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getClassName"); |
| | | |
| | | return className; |
| | | } |
| | |
| | | */ |
| | | public String getMethodName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getMethodName"); |
| | | |
| | | return methodName; |
| | | } |
| | |
| | | */ |
| | | public String getHTMLSafeMethodName() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getHTMLSafeMethodName"); |
| | | |
| | | int length = methodName.length(); |
| | | StringBuilder buffer = new StringBuilder(length + 6); |
| | |
| | | */ |
| | | public HashMap<Integer,Long> getLineNumbers() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getLineNumbers"); |
| | | |
| | | return lineNumbers; |
| | | } |
| | |
| | | */ |
| | | public void updateLineNumberCount(int lineNumber, long numOccurrences) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "updateLineNumberCount", |
| | | String.valueOf(lineNumber), |
| | | String.valueOf(numOccurrences)); |
| | | |
| | | Long existingCount = lineNumbers.get(lineNumber); |
| | | if (existingCount == null) |
| | |
| | | */ |
| | | public long getTotalCount() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getTotalCount"); |
| | | |
| | | long totalCount = 0; |
| | | |
| | |
| | | */ |
| | | public ProfileStackFrame[] getSubordinateFrames() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSubordinateFrames"); |
| | | |
| | | ProfileStackFrame[] subFrames = new ProfileStackFrame[0]; |
| | | subFrames = subordinateFrames.values().toArray(subFrames); |
| | |
| | | */ |
| | | public boolean hasSubFrames() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "hasSubFrames"); |
| | | |
| | | return (! subordinateFrames.isEmpty()); |
| | | } |
| | |
| | | public void recurseSubFrames(ProfileStack stack, int depth, long count, |
| | | HashMap<String,HashMap<ProfileStack,Long>> stacksByMethod) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "recurseSubFrames"); |
| | | |
| | | if (depth < 0) |
| | | { |
| | |
| | | */ |
| | | public int hashCode() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "hashCode"); |
| | | |
| | | return (className.hashCode() + methodName.hashCode()); |
| | | } |
| | |
| | | */ |
| | | public boolean equals(Object o) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "equals", String.valueOf(o)); |
| | | |
| | | if (o == null) |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "equals", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | return false; |
| | | } |
| | |
| | | public int compareTo(Object o) |
| | | throws ClassCastException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "compareTo", String.valueOf(o)); |
| | | |
| | | ProfileStackFrame f; |
| | | try |
| | |
| | | */ |
| | | public String toString() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString"); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append(getTotalCount()); |