debug.Trace_ Extends
Class used for singleton goog.debug.Trace. Used for timing slow points in the code. Based on the java Tracer class but optimized for javascript. See com.google.common.tracing.Tracer.

Inheritance

Constructor

goog.debug.Trace_()

Instance Methods

Public Protected Private
addComment(commentopt_typeopt_timeStamp)
Adds a comment to the trace. Makes it possible to see when a specific event happened in relation to the traces.
Arguments:
comment : string
A comment that is inserted into the trace.
opt_type : ?string=
Type used to identify the tracer. If a comment is given a type and multiple comments are done on that type then a "TOTAL line will be produced showing the total number of comments of that type.
opt_timeStamp : ?number=
The timestamp to insert the comment. If not specified, the current time wil be used.
code »
clearCurrentTrace()
Clears the current trace
code »
getFormattedTrace() string
Returns a formatted string for the current trace
Returns: string  A formatted string that shows the timings of the current trace.
code »
getStat_(type) goog.debug.Trace_.Stat_
Gets a stat object for a particular type. The stat object is created if it hasn't yet been.
Arguments:
type : string
The type of stat.
Returns: goog.debug.Trace_.Stat_  The stat object.
code »
getTotalVarAlloc() number
Returns the total number of allocations since the GC stats were reset. Only works in IE.
Returns: number  The number of allocaitons or -1 if not supported.
code »
initCurrentTrace(defaultThreshold)
Initializes and resets the current trace
Arguments:
defaultThreshold : number
The default threshold below which the tracer output will be supressed. Can be overridden on a per-Tracer basis.
code »
reset(defaultThreshold)
Resets the trace.
Arguments:
defaultThreshold : number
The default threshold below which the tracer output will be supressed. Can be overridden on a per-Tracer basis.
code »
setGcTracer(gcTracer)
Sets the ActiveX object that can be used to get GC tracing in IE6.
Arguments:
gcTracer : Object
GCTracer ActiveX object.
code »
setStartTime(startTime)
Add the ability to explicitly set the start time. This is useful for example for measuring initial load time where you can set a variable as soon as the main page of the app is loaded and then later call this function when the Tracer code has been loaded.
Arguments:
startTime : number
The start time to set.
code »
startTracer(commentopt_type) number
Starts a tracer
Arguments:
comment : string
A comment used to identify the tracer. Does not need to be unique.
opt_type : string=
Type used to identify the tracer. If a Trace is given a type (the first argument to the constructor) and multiple Traces are done on that type then a "TOTAL line will be produced showing the total number of traces and the sum of the time ("TOTAL Database 2 (37 ms)" in our example). These traces should be mutually exclusive or else the sum won't make sense (the time will be double counted if the second starts before the first ends).
Returns: number  The identifier for the tracer that should be passed to the the stopTracer method.
code »
stopTracer(idopt_silenceThreshold) ?number
Stops a tracer
Arguments:
id : number | undefined | null
The id of the tracer that is ending.
opt_silenceThreshold : number=
Threshold below which the tracer is silenced.
Returns: ?number  The elapsed time for the tracer or null if the tracer identitifer was not recognized.
code »
toString() string
Returns a formatted string that describes the thread trace.
Returns: string  A formatted string.
code »

Instance Properties

MAX_TRACE_SIZE :
Maximum size of the trace before we discard events
Code »
commentCount_ :
Total number of comments created in the trace.
Code »
defaultThreshold_ :
Default threshold below which a tracer shouldn't be reported
Code »
A pool for goog.debug.Trace_.Event_ objects so we don't keep creating and garbage collecting these (which is very expensive in IE6).
Code »
events_ :
Events in order.
Code »
No description.
Code »
logger_ : goog.debug.Logger
Logger for the tracer
Code »
nextId_ :
Next id to use for the trace.
Code »
outstandingEvents_ : goog.structs.Map
Outstanding events that have started but haven't yet ended. The keys are numeric ids and the values are goog.debug.Trace_.Event_ objects.
Code »
startTime_ :
Start time of the event trace
Code »
A pool for goog.debug.Trace_.Stat_ objects so we don't keep creating and garbage collecting these (which is very expensive in IE6).
Code »
stats_ : goog.structs.Map
Keeps stats on different types of tracers. The keys are strings and the values are goog.debug.Stat
Code »
tracerCount_ :
Total number of traces created in the trace.
Code »
tracerOverheadComment_ :
Cummulative overhead of calls to addComment
Code »
tracerOverheadEnd_ :
Cummulative overhead of calls to endTracer
Code »
tracerOverheadStart_ :
Cummulative overhead of calls to startTracer
Code »

Static Methods

goog.debug.Trace_.formatTime_(time) string
Return the sec.ms part of time (if time = "20:06:11.566", "11.566
Arguments:
time : number
The time in MS.
Returns: string  A formatted string as sec.ms'.
code »
goog.debug.Trace_.longToPaddedString_(v) string
Converts 'v' to a string and pads it with up to 3 spaces for improved alignment. TODO there must be a better way
Arguments:
v : number
A number.
Returns: string  A padded string.
code »
goog.debug.Trace_.now() number
Returns the current time. Done through a wrapper function so it can be overridden by application code. Gmail has an ActiveX extension that provides higher precision timing info.
Returns: number  The current time in milliseconds.
code »

Enumerations

goog.debug.Trace_.EventType :
Event type supported by tracer
Constants:
COMMENT
No description.
START
No description.
STOP
No description.
Code »

Package debug

Package Reference