#!/usr/bin/env node
import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
import Database from "better-sqlite3";
import { join } from "path";
import { existsSync } from "fs";
import { PerformanceBenchmark } from "../src/core/performance/performance-benchmark.js";
import { logger } from "../src/core/monitoring/logger.js";
async function runBenchmarks() {
  const projectRoot = process.cwd();
  const dbPath = join(projectRoot, ".stackmemory", "context.db");
  if (!existsSync(dbPath)) {
    console.error(
      '\u274C StackMemory not initialized. Run "stackmemory init" first.'
    );
    process.exit(1);
  }
  const db = new Database(dbPath, { readonly: false });
  const projectId = "benchmark-test";
  console.log("\u{1F680} Starting Performance Benchmarks...\n");
  const benchmark = new PerformanceBenchmark();
  try {
    const suite = await benchmark.runFullSuite(projectRoot, db, projectId);
    console.log("\n\u2705 Benchmarks completed successfully!");
    if (suite.averageImprovement > 0) {
      console.log(
        `
\u{1F389} Overall performance improved by ${suite.averageImprovement.toFixed(1)}%`
      );
    }
    process.exit(0);
  } catch (error) {
    console.error("\n\u274C Benchmark failed:", error);
    logger.error("Benchmark error", error);
    process.exit(1);
  } finally {
    db.close();
  }
}
if (import.meta.url === `file://${process.argv[1]}`) {
  runBenchmarks().catch(console.error);
}
export {
  runBenchmarks
};
//# sourceMappingURL=benchmark-performance.js.map
