Skip to main content

PerfUtils

Import :

const PerfUtils = brackets.getModule("utils/PerfUtils")

_

This is a collection of utility functions for gathering performance data.

Kind: global variable

createPerfMeasurement(id, name)

Create a new PerfMeasurement key. Adds itself to the module export. Can be accessed on the module, e.g. PerfUtils.MY_PERF_KEY.

Kind: global function

ParamTypeDescription
idstringUnique ID for this measurement name
namenameA short name for this measurement

markStart(name) ⇒ Object | Array.<Object>

Start a new named timer. The name should be as descriptive as possible, since this name will appear as an entry in the performance report. For example: "Open file: /Users/brackets/src/ProjectManager.js"

Multiple timers can be opened simultaneously.

Returns an opaque set of timer ids which can be stored and used for calling addMeasurement(). Since name is often creating via concatenating strings this return value allows clients to construct the name once.

Kind: global function
Returns: Object | Array.<Object> - Opaque timer id or array of timer ids.

ParamTypeDescription
namestring | Array.<string>Single name or an Array of names.

addMeasurement(id)

Stop a timer and add its measurements to the performance data.

Multiple measurements can be stored for any given name. If there are multiple values for a name, they are stored in an Array.

If markStart() was not called for the specified timer, the measured time is relative to app startup.

Kind: global function

ParamTypeDescription
idObjectTimer id.

updateMeasurement(id)

This function is similar to addMeasurement(), but it allows timing the last event, when you don't know which event will be the last one.

Tests that are in the activeTests list, have not yet been added, so add measurements to the performance data, and move test to updatableTests list. A test is moved to the updatable list so that it no longer passes isActive().

Tests that are already in the updatableTests list are updated.

Caller must explicitly remove test from the updatableTests list using finalizeMeasurement().

If markStart() was not called for the specified timer, there is no way to determine if this is the first or subsequent call, so the measurement is not updatable, and it is handled in addMeasurement().

Kind: global function

ParamTypeDescription
idObjectTimer id.

finalizeMeasurement(id)

Remove timer from lists so next action starts a new measurement

updateMeasurement may not have been called, so timer may be in either or neither list, but should never be in both.

Kind: global function

ParamTypeDescription
idObjectTimer id.

isActive(id) ⇒ boolean

Returns whether a timer is active or not, where "active" means that timer has been started with addMark(), but has not been added to perfdata with addMeasurement().

Kind: global function
Returns: boolean - Whether a timer is active or not.

ParamTypeDescription
idObjectTimer id.

getDelimitedPerfData() ⇒ string

Returns the performance data as a tab delimited string

Kind: global function

getData(id)

Returns the measured value for the given measurement name.

Kind: global function

ParamTypeDescription
idObjectThe measurement to retrieve.

getHealthReport() ⇒ Object

Returns the Performance metrics to be logged for health report

Kind: global function
Returns: Object - An object with the health data logs to be sent

searchData(regExp) ⇒ Array

To search data given the regular expression

Kind: global function

ParamTypeDescription
regExpRegExpthe regular expression

clear()

Clear all logs including metric data and active tests.

Kind: global function