UNPKG

traceperf

Version:

High-performance function execution tracking and monitoring for Node.js

66 lines (65 loc) 1.57 kB
/** * High-resolution timing utilities for performance tracking */ /** * Get the current high-resolution time * * @returns The current high-resolution time */ export declare function getHighResTime(): [number, number]; /** * Calculate the duration between a start time and now * * @param startTime - The start time from getHighResTime() * @returns The duration in milliseconds */ export declare function getDuration(startTime: [number, number]): number; /** * Format a duration in milliseconds to a human-readable string * * @param duration - The duration in milliseconds * @returns A formatted string (e.g., "1.23ms", "1.23s") */ export declare function formatDuration(duration: number): string; /** * A simple timer class for measuring durations */ export declare class Timer { private _startTime; private _endTime; private _label; /** * Create a new Timer instance * * @param label - A label for the timer */ constructor(label: string); /** * Stop the timer * * @returns The duration in milliseconds */ stop(): number; /** * Get the duration of the timer * * @returns The duration in milliseconds */ getDuration(): number; /** * Get the label of the timer * * @returns The timer label */ getLabel(): string; /** * Reset the timer */ reset(): void; /** * Get a formatted string with the duration * * @returns A formatted string (e.g., "label: 1.23ms") */ toString(): string; }