import { type ILogObj, Logger } from 'tslog'; import type { BenchmarkOptions, SuiteInit } from './types.js'; interface ImportType { pattern: string; type: 'esm' | 'json'; } interface ResolvedImport extends ImportType { path: string; } /** * The SuiteConfig class is responsible for loading the benchmark configuration * from a file or using the provided options. * It also provides default values for various configuration options. */ export declare class SuiteConfig { readonly kind = "config"; /** * The override options for the benchmark. */ protected initOptions: SuiteInit; /** * The list of files to look for. */ protected readonly files: ImportType[]; /** * The final options for the benchmark. * This includes the options loaded from the configuration file and the constructor options. * @example * ```typescript * const config = new SuiteConfig({ * maxExecutionTime: 1000, * }) * await config.load(); * console.log(config.maxExecutionTime); // 1000 * ``` */ protected options: SuiteInit; /** * Logger instance for logging messages. * This is used to log warnings and errors during the benchmark process. */ logger: Logger; /** * The maximum execution time in milliseconds. * The benchmark will stop after this time has elapsed. * @default 10000 (10 seconds) */ get maxExecutionTime(): number; /** * The number of warmup iterations. * Warmup iterations are run before the actual measurements to allow the JavaScript engine to optimize the code. * @default 10 */ get warmupIterations(): number; /** * The initial number of inner iterations to run per benchmark iteration. * The actual number of inner iterations might be adjusted adaptively based on the `timeThreshold`. * @default 10 */ get innerIterations(): number; /** * The maximum value that the adaptive innerIterations can reach. * This prevents the inner loop from becoming too large for very fast functions. * @default 10000 */ get maxInnerIterations(): number; /** * The target minimum time (in milliseconds) for the inner loop to execute. * If the inner loop completes faster than this threshold, the number of inner iterations * is doubled, up to `maxInnerIterations`, to improve measurement accuracy. * @default 1 */ get timeThreshold(): number; /** * The minimum number of samples to keep after removing outliers. * This ensures that there are enough samples for statistical analysis. * @default 10 */ get minSamples(): number; /** * The maximum number of iterations to run. * This is used to accurately measure the performance of the function. * The benchmark will try to run the function for this number of iterations. * If the function is too slow, the `maxExecutionTime` will end the benchmark after the set time. * @default 100 */ get maxIterations(): number; /** * When set to true, the benchmark will run in debug mode. * This mode is useful for debugging and development purposes. * It may slow down the benchmark execution. * @default false */ get debug(): boolean; /** * The log level used by the `tslog` logger. * This can be set to `0` (silly), `1` (trace), `2` (debug), `3` (info), `4` (warn), `5` (error), or `6` (fatal) * It is set to 5 if `debug` is false. * @default 5 */ get logLevel(): number; /** * Creates a new instance of the SuiteConfig class. * This class is responsible for loading the benchmark configuration from a file or using the provided options. * * @param options The options for the benchmark. These options take precedence over the loaded configuration file. * @example * ```typescript * const config = new SuiteConfig({ * maxExecutionTime: 1000, * warmupIterations: 5, * }) * await config.load(); * console.log(config.maxExecutionTime); // 1000 * console.log(config.warmupIterations); // 5 * ``` */ constructor(options?: SuiteConfig | SuiteInit); /** * Checks if the class has the ability to read files. * This is determined by checking if the environment is Node.js or if the `fs` and `path` modules are provided. * In a browser environment, this method will return false. * * @example * ```typescript * const isValidFilesystem = this.canReadFile(); * console.log(isValidFilesystem); // true if running in Node.js, false otherwise * ``` */ canReadFile(): boolean; /** * Validates the structure of the `path` and `fs` init options. */ protected validateSyntheticNodeModules(): void; /** * Loads the configuration from the file system. * This method will only be called if the environment is Node.js or if the `fs` and `path` modules are provided. * If no config file is found, it will use the constructor options. * * @example * ```typescript * const config = new SuiteConfig({ * maxExecutionTime: 1000, * }) * await config.load(); * console.log(config.maxExecutionTime); // 1000 * ``` */ load(): Promise; /** * Post-processing after loading the configuration file. */ protected postConfigLoad(): void; /** * Finds the configuration file in the current directory or its parents. * @returns The resolved import object or null if not found. */ protected findConfigFile(): Promise; /** * Loads the configuration from the specified file. * This method will only be called if the environment is Node.js or if the `fs` and `path` modules are provided. * @param info The resolved import object containing the file path and type. * @returns The loaded configuration options. */ protected loadFromFile(info: ResolvedImport): Promise; } export {}; //# sourceMappingURL=suite_config.d.ts.map