Allows you to capture the run time of specific Javascript objects' methods so you can see how the code YOU wrote is doing
jQuery
It is recognized that, based on the architecture of this program, profiling your methods using this program slows down your program marginally. We have not yet profiled this program's methods.
-
Put the Caffeine folder on your program's path.
-
If you don't already have jQuery as a script in the head of your HTML, put the following line in your HTML head:
<script src='../Caffeine/jquery-1.8.2.min.js'></script> -
In the head of you HTML file, put following after all of your other requisite JS files
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script> <script src='Caffeine/jsProfiler.js' type='text/javascript'></script> <script src='http://d3js.org/d3.v2.js'></script> <script src='Caffeine/flatGrapher.js' type='text/javascript'></script> <script src='Caffeine/stackedGrapher.js' type='text/javascript'></script> <link rel="stylesheet" type="text/css" href="Caffeine/profiler.css" /> <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /> -
In your Javascript, just pass the instance of your object that will be used throughout your program to a new instance of the Profiler, along with a boolean of if you want the Profiler to make a graph. Then start the Profiler by calling
start()on it. Make sure you callstart()before your object instance does anything, or all of the object's behaviors won't be profiled. For example:lolcat = new LOLCat(); new Profiler(lolcat, true).start();
The application-wide graph alias. Starts off as instance of FlatGrapher
A list of StackObjects representing the top-level functions
An object holding all the MethodObjects
An object representing one of the profiled object's methods
An array of the clocked runtime for each time the represented method was run
Dummy representations of objects that keep track of a method's call stack (which methods it calls, tree-like)
The name of the method that this object represents
An array of StackObjects representing the methods that the represented method calls
Creates a new profiler for the passed in object. If graphing == true, the average runtimes will be in a moveable and scalable graph div appended to the bottom of the page upon starting the Profiler
Begins the runtime analysis.
Helper method that recursively traverses an object's attributes looking for methods, keeping track of each method it finds, and delegating to Profiler.clocker() for timing the methods.
Helper method that wraps a method in clocking code and figures out the call structure of each method. Aids in the creation of the originators object.
Returns the wrapped method.
Super class of FlatGrapher and StackedGrapher
Creates the initial graph. Overridden in subclasses
Redraws the graph. Overridden in subclasses. Refreshes every second.
Scales the graph. Calls redraw(). Overridden in subclasses
Stops the redrawing of the graph
Inherits from Grapher
Creates the initial graph visualization such that each method has it's own bar
Redraws the graph. See Grapher.redraw() for more information.
####FlatGrapher.scale()
Scales the graph.
####FlatGrapher.stop()
Stops the redrawing of the graph
Inherits from Grapher
Creates the initial graph visualization such that each bar represents a top-level method in originators. Nested inside each bar, recursively, are the methods called by the depicted method.
Helper method for StackedGrapher.init() that recursively draws the nested bars
Redraws the graph. See Grapher.redraw() for more information.
Helper method for StackedGrapher.redraw() that recursively redraws the nested bars
Scales the graph.
Stops the redrawing of the graph