aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
92 lines (91 loc) • 2.97 kB
TypeScript
import './dispose-polyfill';
/**
* The field in `detail` that needs to be set to `true` in order to send this to telemetry.
*/
export declare const TELEMETRY_FIELD = "telemetry";
/**
* The field in `detail` that needs to be set to `true` in order to skip this for counting
*/
export declare const SKIPCOUNT_FIELD = "skipCount";
export interface ProfileOptions {
/**
* Whether to include the given profiling information in the report that the CLI sends for telemetry.
*
* @default false
*/
readonly telemetry?: boolean;
/**
* If set to true, do not increment the counter by `1`
*
* This is a trick for if multiple distinct spans should be counted together as time for a single
* conceptual invocation. Used for bundling, use sparingly.
*
* @default false
*/
readonly skipCount?: boolean;
}
/**
* Make a decorator that will profile a given function.
*
* Emits a measurementto the performance timeline, potentially with `{ telemetry: true }` in
* the `detail` field.
*
* If a profiled function is called from another profiled function, only the
* top-level call is accounted for.
*/
export declare function profileFn(key: string, options?: ProfileOptions): <A extends Function>(fn: A) => A;
/**
* Profile a block by returning a disposable that will emit a (non-exclusive) counter when disposed
*
* Recommended way of using this:
*
* ```ts
* using _span = profileSpan('span-name', { telemetry: true });
* ```
*/
export declare function profileSpan(key: string, options?: ProfileOptions): Disposable;
/**
* Make all functions on this given object (exclusively) profiled
*/
export declare function profileObj(objName: string, options?: ProfileOptions): <A extends object>(obj: A) => A;
type ArbitraryConstructor = {
new (...args: any[]): {};
};
/**
* Make all functions on this given class (exclusively) profiled
*/
export declare function profileClass<A extends ArbitraryConstructor>(cls: A, options?: ProfileOptions): A;
export interface PerfCounter {
count: number;
total: number;
}
export type PerfCounters = Record<string, PerfCounter>;
export interface ReadCountersOptions {
/**
* Whether to read only counters emitted for telemetry.
*
* If set to `false`, all counters are read.
*
* @default false
*/
readonly telemetry?: boolean;
/**
* Return at most the top N entries.
*
* @default - All entries
*/
readonly n?: number;
}
/**
* Read measurements from the performance timeline and return them as counters
*
* Returns an ordered map, with the counters with the highest durations first.
*/
export declare function readPerfCounters(options?: ReadCountersOptions): PerfCounters;
/**
* Print a table of the performance counters
*
* This can be used for local debugging and performance analysis.
*/
export declare function printPerfCounters(options?: ReadCountersOptions): void;
export {};