If you have node.js and npm set up, install with:
> npm install --save tinyprofiler
tp.middleware.profiling as the
first middlewares on your stack. If you'd also like to view the results
in the browser, take a look at tinyprofiler-client. See the
example folder for more information.
Isn't MiniProfiler great? Why wouldn't I just use that?
the recursive data structure has the following properties:
id: a guid for the request [root only]
name: the name of the step
details: additional information [optional]
start: the start time of the step [iso date on root]
length: the finish time of the step
steps: any child steps [optional]
all timings are relative to the start time of their parent, and are
recorded in the format of
process.hrtime(). each timing is a pair
of integers - the first the number of seconds since the start of the
parent, and the second the number of nanoseconds.
start entry for the root has an iso date string representing
the start time of the entire profile.
tinyprofiler accepts a variety of configuration options. Many of these are shared between client and server code, but some of them are only applicable to one or the other.
n.b. the following also documents options for tinyprofiler-client.
These opitons should be identical between the client and the server.
the name of the HTTP header to use to send profile ids
server path to mount tinyprofiler REST API
key name on request object to store request-scoped profiler
These options have the same meaning on the client and server, but nevertheless are frequently different in the two environments.
function to build profile name from request object (method defaults to "AJAX" on client)
function to build profile details from request object
do we automatically profile the server response?
the maximum number of old profiles to hold on to.
do we automatically monkey patch the XHR object?
do we automatically profile each XHR request?
TinyProfiler extends EventEmitter2 to provide status updates to
any listeners you may have. TinyProfiler emits two events:
update is emitted any time there is new step timing
complete is emitted after each completed request.
Both are supplied with the relevant request profiler object.