interface InstrumentHooks$1 { /** * Check if instrumentation is enabled */ isInstrumented(): boolean; /** * Start benchmark measurement * @returns 0 on success, non-zero on error */ startBenchmark(): number; /** * Stop benchmark measurement * @returns 0 on success, non-zero on error */ stopBenchmark(): number; /** * Set the executed benchmark metadata * @param pid Process ID * @param uri Benchmark URI/identifier * @returns 0 on success, non-zero on error */ setExecutedBenchmark(pid: number, uri: string): number; /** * Set integration metadata * @param name Integration name * @param version Integration version * @returns 0 on success, non-zero on error */ setIntegration(name: string, version: string): number; /** * Register a key-value pair under a named environment section. * @param sectionName Section name (e.g. "Node.js") * @param key Key name (e.g. "version") * @param value Value (e.g. "22.0.0") * @returns 0 on success, non-zero on error */ setEnvironment(sectionName: string, key: string, value: string): number; /** * Flush all registered environment sections to disk. * @param pid Process ID * @returns 0 on success, non-zero on error */ writeEnvironment(pid: number): number; /** * Returns a high-resolution timestamp (nanoseconds) suitable for marker * emission. Mirrors `instrument_hooks_current_timestamp` in the C API. */ currentTimestamp(): bigint; /** * Emit a marker for the given pid at the given timestamp. * @param pid Process ID * @param markerType One of MARKER_TYPE_* * @param timestamp Timestamp (typically obtained from `currentTimestamp()`) * @returns 0 on success, non-zero on error */ addMarker(pid: number, markerType: number, timestamp: bigint): number; /** * Add an object file to callgrind's obj-skip list, as `--obj-skip` does. * Only affects code callgrind has not instrumented yet. No-op outside * Valgrind. * @param path Path of the object file, resolved to its real path * @returns 0 on success, non-zero on error */ callgrindAddObjSkip(path: string): number; /** * Execute a callback function with __codspeed_root_frame__ in its stack trace * @param callback Function to execute */ __codspeed_root_frame__(callback: () => T): T; /** * Marker type constants, exposed by the native addon from core.h. * Used as the `markerType` argument to {@link addMarker}. */ readonly MARKER_TYPE_SAMPLE_START: number; readonly MARKER_TYPE_SAMPLE_END: number; readonly MARKER_TYPE_BENCHMARK_START: number; readonly MARKER_TYPE_BENCHMARK_END: number; } type SetupInstrumentsRequestBody = { /** * The full `MONGO_URL` that is usually used to connect to the database. */ mongoUrl: string; }; type SetupInstrumentsResponse = { /** * The patched `MONGO_URL` that should be used to connect to the database. */ remoteAddr: string; }; declare class MongoMeasurement { private tracerClient; constructor(); setupInstruments(body: SetupInstrumentsRequestBody): Promise; start(uri: string): Promise; stop(uri: string): Promise; } declare const getV8Flags: () => string[]; declare const tryIntrospect: () => void; /** * Majors CodSpeed is tested against. The native addon itself is built as a * single Node-API binary and loads on any major, so this only gates the * warning about measurement stability. * * IMPORTANT: Keep in sync with the support matrix on the backend! */ declare const SUPPORTED_NODE_MAJORS: number[]; declare function getUnsupportedNodeVersionWarning(version: string): string | null; /** * On GitHub Actions the warning becomes an annotation, which is shown outside * the job log. Workflow commands must start a line, hence the direct stdout * write rather than a prefixed log call. */ declare function warnCi(message: string, title: string): void; /** * Integrations call their setup path per suite or per worker, so the warning is * latched to once per process. */ declare function warnOnUnsupportedNodeVersion(): void; declare const optimizeFunction: (fn: CallableFunction) => Promise; declare const optimizeFunctionSync: (fn: CallableFunction) => void; /** * Wrap a benchmark function so it executes under a frame named * `__codspeed_root_frame__`. CodSpeed uses this frame to locate the * benchmark root in collected call stacks; samples without it cannot be * attributed to a benchmark. */ declare function wrapWithRootFrame(fn: () => T | Promise): () => Promise; declare function wrapWithRootFrameSync(fn: () => T): () => T; type CodSpeedRunnerMode = "disabled" | "simulation" | "memory" | "walltime"; type InstrumentMode = "disabled" | "analysis" | "walltime"; declare function getCodspeedRunnerMode(): CodSpeedRunnerMode; declare function getInstrumentMode(): InstrumentMode; /** * Return the root of the git repository containing `from`. `.git` is a * directory in a regular clone and a file in worktrees and submodules. */ declare function getGitDir(from: string): string | undefined; /** * Return the file that called the function this is invoked from, expressed as * a path relative to the enclosing git repository root. * * The `depth` parameter is the number of stack frames to skip past * `getCallingFile` itself. Pass `0` to get the file of the function that * called `getCallingFile`, `1` to skip one further frame (for indirection * through a helper), and so on. */ declare function getCallingFile(depth: number): string; /** * Log debug messages if the environment variable `CODSPEED_DEBUG` is set. */ declare function logDebug(...args: unknown[]): void; interface BenchmarkStats { min_ns: number; max_ns: number; mean_ns: number; stdev_ns: number; q1_ns: number; median_ns: number; q3_ns: number; rounds: number; total_time: number; iqr_outlier_rounds: number; stdev_outlier_rounds: number; iter_per_round: number; warmup_iters: number; } interface BenchmarkConfig { warmup_time_ns: number | null; min_round_time_ns: number | null; max_time_ns?: number | null; max_rounds?: number | null; } interface Benchmark { name: string; uri: string; config: BenchmarkConfig; stats: BenchmarkStats; } interface InstrumentInfo { type: string; } interface ResultData { creator: { name: string; version: string; pid: number; }; instrument: { type: "walltime"; }; benchmarks: Benchmark[]; metadata?: Record; } declare function calculateQuantiles({ sortedTimesNs, stdevNs, meanNs, }: { sortedTimesNs: number[]; stdevNs: number; meanNs: number; }): { q1_ns: number; median_ns: number; q3_ns: number; iqr_outlier_rounds: number; stdev_outlier_rounds: number; }; /** * Converts nanoseconds to milliseconds. * @param ns - the nanoseconds to convert * @returns the milliseconds */ declare const nsToMs: (ns: number) => number; /** * Converts milliseconds to nanoseconds. * @param ms - the milliseconds to convert * @returns the nanoseconds */ declare const msToNs: (ms: number) => number; /** * Converts milliseconds to seconds. * @param ms - the milliseconds to convert * @returns the seconds */ declare const msToS: (ms: number) => number; declare function getProfileFolder(): string | null; declare function writeWalltimeResults(benchmarks: Benchmark[], asyncWarning?: boolean): void; declare const isBound: boolean; declare const mongoMeasurement: MongoMeasurement; declare const setupCore: () => void; declare const teardownCore: () => void; declare const InstrumentHooks: InstrumentHooks$1; declare const MARKER_TYPE_SAMPLE_START: number; declare const MARKER_TYPE_SAMPLE_END: number; declare const MARKER_TYPE_BENCHMARK_START: number; declare const MARKER_TYPE_BENCHMARK_END: number; export { type Benchmark, type BenchmarkConfig, type BenchmarkStats, InstrumentHooks, type InstrumentInfo, type InstrumentMode, MARKER_TYPE_BENCHMARK_END, MARKER_TYPE_BENCHMARK_START, MARKER_TYPE_SAMPLE_END, MARKER_TYPE_SAMPLE_START, type ResultData, SUPPORTED_NODE_MAJORS, type SetupInstrumentsRequestBody, type SetupInstrumentsResponse, calculateQuantiles, getCallingFile, getCodspeedRunnerMode, getGitDir, getInstrumentMode, getProfileFolder, getUnsupportedNodeVersionWarning, getV8Flags, isBound, logDebug, mongoMeasurement, msToNs, msToS, nsToMs, optimizeFunction, optimizeFunctionSync, setupCore, teardownCore, tryIntrospect, warnCi, warnOnUnsupportedNodeVersion, wrapWithRootFrame, wrapWithRootFrameSync, writeWalltimeResults }; //# sourceMappingURL=index.d.ts.map