import { DEFAULT_REGEX_LIMITS } from "../execution/request-limits";
import type { BenchmarkSettings, GrowthSettings } from "./analysis.types";

export const ANALYSIS_LIMITS = {
  maximumWarmupIterations: 100,
  maximumMeasuredIterations: 1_000,
  maximumGrowthSteps: 24,
  maximumGrowthFragmentUtf16: 4_096,
  maximumGrowthAffixUtf16: 16_384,
  maximumGrowthRepetitions: 10_000_000,
  maximumReplacementBenchmarkOutputUtf16: 8 * 1024 * 1024,
  minimumSampleTimeoutMs: 25,
  maximumSampleTimeoutMs: DEFAULT_REGEX_LIMITS.advancedMaximumTimeoutMs,
  maximumAnalysisWallTimeMs: DEFAULT_REGEX_LIMITS.maximumBenchmarkWallTimeMs,
} as const;

export const DEFAULT_BENCHMARK_SETTINGS: BenchmarkSettings = {
  warmupIterations: 3,
  measuredIterations: 15,
  sampleTimeoutMs: 2_000,
  maximumWallTimeMs: DEFAULT_REGEX_LIMITS.maximumBenchmarkWallTimeMs,
};

export const DEFAULT_GROWTH_SETTINGS: GrowthSettings = {
  prefix: "",
  repeatedFragment: "a",
  suffix: "!",
  startingRepetitions: 16,
  maximumRepetitions: 16_384,
  multiplier: 2,
  maximumSteps: 11,
  sampleTimeoutMs: 1_000,
  maximumWallTimeMs: DEFAULT_REGEX_LIMITS.maximumBenchmarkWallTimeMs,
  maximumSubjectBytes: 1024 * 1024,
  normalizedGrowthThreshold: 4,
};
