Module: timing

cycligent. timing

Cycligent timing simplifies performance measurement in asynchronous applications. It is basically a continuous timeline that can reviewed. It provides durations of events, including idle time. Cycligent timing is timeline/event oriented. You do not have to issue starts and stops for each item you want to time. Instead you just signal events and Cycligent does the rest.
  • Event Organization

    Cycligent timing events can be organized by using indent and unindent functions. These events can then be viewed in a tree fashion. Cycligent extends the indent/unindent approach to handle idle events that are hard to signal because of multiple overlapping asynchronous processes needing to complete. The start of such events can be signaled via cycligent.timing.asyncBegin or cycligent.timing.idleIndent. The async process can then be completed either cycligent.timing.idle or cycligent.timing.asyncEnd. When the last asynchronous operation completes the application is marked as idle on the timeline.

  • Idle Tracking & Overlapping Asynchronous Events

    Multiple overlapping asynchronous events can cause the timeline durations to become muddled (the exact duration of a given operation being cut short by another event with another event looking like it took lonoger). Cycligent timing does its best to rectify these issues where possible. That being said, Cycligent does not try to eliminate these occurrences. This is because in practice the items are easy to identify when viewed and it is possible to determine the duration of a given process from the timeline. We have, therefore, favored keeping the API, and the output, simple.

  • External Timing Inclusion

    Cycligent timing also provides for the inclusion of external performance (timing) information. Normally a duration is not supplied to cycligent.timing.event or other event signalling functions. But, if a duration is supplied, then the event is marked as occurring externally. This is useful for including server processing times, such as database query times, in the timeline. The timeline still tracks durations on either side of the external events with actual durations. If the immediately preceding event in the timeline is at the same indent level as the first external event (usually a single event with descendents) then it duration is automatically subtracted from the duration of the preceding event, which would have normally been the case had the external events occurred internally.

  • Timing Start

    Cycligent automatically starts timing as soon as it is loaded. You can measure from an earlier point by adding a script tag to the top of your HEAD section, in the initial HTML file loaded, that sets the global variable cycligentRunningBase to the time from which you want to being the running timer. See the example below. The example provided measures everything but the time it takes to load the initial HTML file. All scripts, css, etc that it loads, even in the head section, are measured.
Source:

Example

Setting the startring load time via cycligentRunningBase (place at the
top of your HEAD section):

    <script>window.cycligentRunningBase = (new Date()).getTime();</script>

Example of using timings from within an angularjs application:

cycligent.timing.eventIndent(false, "Get data", 1);
$http.get('/api/data/all')
    .success(function (data) {
        cycligent.timing.event("Process data", 1);
        for (var d in data) {
            processData(data[d]);
        }
        cycligent.timing.event("Process view", 1);
        deferred.resolve(data);
        cycligent.timing.idle();
    });

Classes

TimingEvent

Members

(static) events :Array.<cycligent.timing.TimingEvent>

Array of timing events
Type:
  • Array.<cycligent.timing.TimingEvent>
Source:

Methods

(static) asyncBegin(title, indentopt)

Begins tracking of an asynchronous process and increases the idle indent.

Cycligent extends the indent/unindent approach (see cycligent.timing.indent and cycligent.timing.unindent) to handle idle events that are hard to signal because of multiple overlapping asynchronous processes needing to complete. The start of such events can be signaled via cycligent.timing.asyncBegin or cycligent.timing.idleIndent. The async process can then be completed either cycligent.timing.idle or cycligent.timing.asyncEnd. When the last asynchronous operation completes the application is marked as idle on the timeline.
Parameters:
Name Type Attributes Description
title string Title of timing event.
indent int <optional>
The nested level of the event. If not provided the current indent level is used. The current indent level is the indent last provided to an Event constructor or as modified by cycligent.timing.indent or cycligent.timing.unindent.
Source:

(static) asyncEnd()

End tracking of an asynchronous event and decreases the idle indent. Identical to cycligent.timing.idle.

Cycligent extends the indent/unindent approach (see cycligent.timing.indent and cycligent.timing.unindent) to handle idle events that are hard to signal because of multiple overlapping asynchronous processes needing to complete. The start of such events can be signaled via cycligent.timing.asyncBegin or cycligent.timing.idleIndent. The async process can then be completed either cycligent.timing.idle or cycligent.timing.asyncEnd. When the last asynchronous operation completes the application is marked as idle on the timeline.
Source:

(static) clear()

Clear console messages
Source:

(static) event(title, indentopt, durationopt)

Signals a timing event
Parameters:
Name Type Attributes Description
title string Title of timing event.
indent int <optional>
The nested level of the event. If not provided the current indent level is used. The current indent level is the indent last provided to an Event constructor or as modified by cycligent.timing.indent or cycligent.timing.unindent.
duration int <optional>
Milliseconds event lasted. Only used when the event occurred out-of-band (such as on a server) and the event is being logged to account for those times (such as the time it took for a query to run on the server).
Source:

(static) eventIndent(increaseIdleIndent, title, indentopt, title2opt)

Creates a primary event and its first indented event.

The first indented event, being created at the same time as the primary event, ensures that the indented event durations will total the primary event duration. Durations might not otherwise total the primary event duration because of time passing between the creation of the primary event and its first child event. This is normal but some people like to see the totals add up. While this could be accomplished by simply calling cycligent.timing.event in succession, this event provides the same functionality in a single call.

In addition to just making the childrens' durations total the primary duration, this function can increase the idle indent. Idle indent allows the determination of an idle state easier when there are multiple overlapping asynchronous events. See cycligent.timing for more information.
Parameters:
Name Type Attributes Description
increaseIdleIndent boolean
title string
indent int <optional>
The nested level of the primary (first) event. If not provided the current indent level is used. The current indent level is the indent last provided to an Event constructor or as modified by cycligent.timing.indent or cycligent.timing.unindent.
title2 string <optional>
The title of the first indented event to the primary event, which is created automatically. Title2 defaults to "Network/Other" and serves as a catch all for any time not required by other segments occurring under the primary event.
Source:

(static) idle()

Indicates that the application is in an idle state, or is potentially in an idle state in the case of multiple overlapping asynchronous events.

Cycligent extends the indent/unindent approach (see cycligent.timing.indent and cycligent.timing.unindent) to handle idle events that are hard to signal because of multiple overlapping asynchronous processes needing to complete. The start of such events can be signaled via cycligent.timing.asyncBegin or cycligent.timing.idleIndent. The async process can then be completed either cycligent.timing.idle or cycligent.timing.asyncEnd. When the last asynchronous operation completes the application is marked as idle on the timeline.
Source:

(static) idleIndent()

Increases the idle indent

Cycligent extends the indent/unindent approach (see cycligent.timing.indent and cycligent.timing.unindent) to handle idle events that are hard to signal because of multiple overlapping asynchronous processes needing to complete. The start of such events can be signaled via cycligent.timing.asyncBegin or cycligent.timing.idleIndent. The async process can then be completed either cycligent.timing.idle or cycligent.timing.asyncEnd. When the last asynchronous operation completes the application is marked as idle on the timeline.
Source:

(static) indent()

Increase the current indent level by one, up to a maximum of 25.
Source:

(static) notify(func)

Register a notification function
Parameters:
Name Type Description
func function The function to be called whenever a timing event is logged or timings are cleared. The notify function should accept one argument (cycligent.timing.TimingEvent) which will be contain the new timing segment. If the segment is not passed to the function (undefined) then the timings were cleared.
Source:

(static) notifyClear(func)

Unregister a notification function
Parameters:
Name Type Description
func function The notify function to unregister.
Source:

(static) unindent()

Decrease the current indent level by one, to a minimum of 0.
Source: