UNPKG

@stacksjs/dtsx

Version:

A modern, fast .d.ts generation tool, powered by Bun.

102 lines (101 loc) 2.47 kB
import type { ProfilingConfig } from './types'; /** * Create a new profiler instance */ export declare function createProfiler(config?: ProfilingConfig): Profiler; /** * Profile a function execution */ export declare function profileExecution<T>(fn: () => T | Promise<T>, config?: ProfilingConfig): Promise<{ result: T, profile: ProfilingResults }>; /** * Create a profiled I/O wrapper */ export declare function createProfiledIo(profiler: Profiler): { read: <T>(path: string, fn: () => Promise<T>) => Promise<T> write: (path: string, fn: () => Promise<void>, size: number) => Promise<void> }; /** * Create a simple timer */ export declare function createTimer(): Timer; /** * Memory profiling data snapshot */ export declare interface MemoryProfileSnapshot { timestamp: number heapUsed: number heapTotal: number external: number arrayBuffers: number rss: number } /** * CPU profiling data */ export declare interface CpuProfile { timestamp: number user: number system: number total: number } /** * I/O operation record */ export declare interface IoOperation { timestamp: number operation: 'read' | 'write' path: string size: number durationMs: number } /** * Profiling results */ export declare interface ProfilingResults { startTime: number endTime: number durationMs: number memory: { samples: MemoryProfileSnapshot[] peak: MemoryProfileSnapshot average: MemoryProfileSnapshot warnings: string[] } cpu: { samples: CpuProfile[] totalUser: number totalSystem: number } io: { operations: IoOperation[] totalReads: number totalWrites: number totalReadBytes: number totalWriteBytes: number totalReadMs: number totalWriteMs: number } } /** * Profiler class for collecting performance data */ export declare class Profiler { constructor(config?: ProfilingConfig); start(): void; stop(): void; recordIo(operation: 'read' | 'write', path: string, size: number, durationMs: number): void; getResults(): ProfilingResults; formatResults(): string; writeResults(): Promise<void>; } /** * Simple timer for manual profiling */ export declare class Timer { mark(name: string): void; measure(name: string, fromMark: string): number; getDurations(name: string): number[]; getAverage(name: string): number; getSummary(): Map<string, { count: number, total: number, average: number, min: number, max: number }>; clear(): void; }