traceperf
Version:
High-performance function execution tracking and monitoring for Node.js
66 lines (65 loc) • 1.75 kB
TypeScript
/**
* Module for defining common types used throughout the application
*/
/**
* Options for tracking function execution
*/
export interface ITrackOptions {
/**
* Custom label for the function
*/
label?: string;
/**
* Threshold in milliseconds for slow function detection
*/
threshold?: number;
/**
* Whether to include memory usage in the tracking
*/
includeMemory?: boolean;
/**
* Whether to enable nested function tracking
* If true, functions called within the tracked function will also be tracked
* Default: true
*/
enableNestedTracking?: boolean;
}
/**
* Interface for execution trackers
*/
export interface IExecutionTracker {
/**
* Track the execution of a function
*
* @param fn - The function to track
* @param options - Options for tracking
* @returns The return value of the tracked function
*/
track<T>(fn: () => T, options?: ITrackOptions): T;
/**
* Create a trackable version of a function
*
* @param fn - The function to make trackable
* @param options - Options for tracking
* @returns A tracked version of the function
*/
createTrackable<T extends (...args: any[]) => any>(fn: T, options?: Omit<ITrackOptions, 'label'> & {
label?: string;
}): (...args: Parameters<T>) => ReturnType<T>;
/**
* Get the current call stack
*
* @returns The current call stack
*/
getCallStack(): string[];
/**
* Generate a visual representation of the execution flow
*
* @returns ASCII flow chart of the execution
*/
generateFlowChart(): string;
/**
* Clear all execution records
*/
clear(): void;
}