INNER CODE UNIT · TypeScript

timestamps

oomol-lab/open-connector · scripts/benchmark-sqlite-token-statements.ts:36

const timestamps = Array.from({ length: 30_000 }, (_, index) => new Date(1_790_726_400_000 + index).toISOString());

async function measure(store: SqliteRuntimeTokenStore, iterations: number): Promise<number> {
  const start = performance.now();
  for (let index = 0; index < iterations; index++) {
    const token = await store.findByHash(hashes[index % tokenCount]);
    if (!token) throw new Error("Benchmark token is missing.");
    await store.markUsed(token.id, timestamps[index]);
  }
  return performance.now() - start;
}

function median(values: number[]): number {
  return [...values].sort((left, right) => left - right)[Math.floor(values.length / 2)];
}

async function benchmark(filename: string, iterations: number, schema?: string): Promise<void> {
  const database = new DatabaseSync(filename);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…