toolkit/components/perfmonitoring/nsIPerformanceStats.idl
author David Rajchenbach-Teller <dteller@mozilla.com>
Fri, 02 Oct 2015 23:44:23 +0200
changeset 303850 33afbc6c499777e07ae520cd83cbf9f57de252df
parent 288541 14ae070d4a419ea30357a588985694b35f63ae2b
child 303855 10f906d69805a39c1f99fbc78f3a6b87a70225c0
permissions -rw-r--r--
Bug 1208747 - Move most of Stopwatch-related code to XPCOM-land (XPCOM-level + XPConnect-level);r=froydnj

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-*/
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsIArray.idl"
#include "nsIDOMWindow.idl"

/**
 * Mechanisms for querying the current process about performance
 * information.
 *
 * JavaScript clients should rather use PerformanceStats.jsm.
 */

/**
 * Snapshot of the performance of a component, e.g. an add-on, a web
 * page, system built-ins, a module or the entire process itself.
 *
 * All values are monotonic and are updated only when
 * `nsIPerformanceStatsService.isStopwatchActive` is `true`.
 */
[scriptable, uuid(f171c901-1888-4087-a002-c2751e510f92)]
interface nsIPerformanceStats: nsISupports {
  /**
   * An identifier unique to the component.
   *
   * This identifier is somewhat human-readable to aid with debugging,
   * but clients should not rely upon the format.
   */
  readonly attribute AString groupId;

  /**
   * A somewhat human-readable name for the component.
   */
  readonly attribute AString name;

  /**
   * If the component is an add-on, the ID of the addon,
   * otherwise an empty string.
   */
  readonly attribute AString addonId;

  /**
   * If the component is code executed in a window, the ID of the topmost
   * outer window (i.e. the tab), otherwise 0.
   */
  readonly attribute uint64_t windowId;

  /**
   * Total amount of time spent executing code in this group, in
   * microseconds.
   */
  readonly attribute unsigned long long totalUserTime;
  readonly attribute unsigned long long totalSystemTime;
  readonly attribute unsigned long long totalCPOWTime;

  /**
   * Total number of times code execution entered this group,
   * since process launch. This may be greater than the number
   * of times we have entered the event loop.
   */
  readonly attribute unsigned long long ticks;

  /**
   * `true` if this component is executed with system privileges
   * (e.g. the platform itself or an add-on), `false` otherwise
   * (e.g. webpages).
   */
  readonly attribute bool isSystem;

  /**
   * The process running this group.
   */
  readonly attribute unsigned long long processId;

  /**
   * Jank indicator.
   *
   * durations[i] == number of times execution of this group
   * lasted at lest 2^i ms.
   */
  void getDurations([optional] out unsigned long aCount,
                    [retval, array, size_is(aCount)]out unsigned long long aNumberOfOccurrences);
};

/**
 * A snapshot of the performance data of the process.
 */
[scriptable, uuid(0ac38e2a-2613-4e3f-9f21-95f085c177de)]
interface nsIPerformanceSnapshot: nsISupports {
  /**
   * Data on all individual components.
   */
  nsIArray getComponentsData();

  /**
   * Information on the process itself.
   *
   * This contains the total amount of time spent executing JS code,
   * the total amount of time spent waiting for system calls while
   * executing JS code, the total amount of time performing blocking
   * inter-process calls, etc.
   */
  nsIPerformanceStats getProcessData();
};

[scriptable, builtinclass, uuid(aad18f7c-9ff7-4e22-8cd1-60ab0b57c698)]
interface nsIPerformanceStatsService : nsISupports {
  /**
   * `true` if we should monitor CPOW, `false` otherwise.
   */
  [implicit_jscontext] attribute bool isMonitoringCPOW;

  /**
   * `true` if we should monitor jank, `false` otherwise.
   */
  [implicit_jscontext] attribute bool isMonitoringJank;

  /**
   * `true` if all compartments need to be monitored individually,
   * `false` if only performance groups (i.e. entire add-ons, entire
   * webpages, etc.) need to be monitored.
   */
  [implicit_jscontext] attribute bool isMonitoringPerCompartment;

  /**
   * Capture a snapshot of the performance data.
   */
  [implicit_jscontext] nsIPerformanceSnapshot getSnapshot();
};

%{C++
#define NS_TOOLKIT_PERFORMANCESTATSSERVICE_CID {0xfd7435d4, 0x9ec4, 0x4699, \
      {0xad, 0xd4, 0x1b, 0xe8, 0x3d, 0xd6, 0x8e, 0xf3} }
#define NS_TOOLKIT_PERFORMANCESTATSSERVICE_CONTRACTID "@mozilla.org/toolkit/performance-stats-service;1"
%}