docs: overhaul retrieval accuracy benchmark

This commit is contained in:
Johann Schopplich
2025-10-28 20:22:43 +01:00
parent efbe4ded88
commit 67c0df8cb0
22 changed files with 1553 additions and 27288 deletions

View File

@@ -1,6 +1,6 @@
import * as fsp from 'node:fs/promises'
import * as path from 'node:path'
import { consola } from 'consola'
import * as prompts from '@clack/prompts'
import { encode } from '../../src/index'
import githubRepos from '../data/github-repos.json' with { type: 'json' }
import { BENCHMARKS_DIR, ROOT_DIR } from '../src/constants'
@@ -24,8 +24,6 @@ interface BenchmarkResult {
showDetailed: boolean
}
const outputFilePath = path.join(BENCHMARKS_DIR, 'results', 'token-efficiency.md')
const BENCHMARK_EXAMPLES = [
{
name: 'GitHub Repositories',
@@ -50,6 +48,8 @@ const BENCHMARK_EXAMPLES = [
},
] as const
prompts.intro('Token Efficiency Benchmark')
// Calculate total savings
let totalJsonTokens = 0
let totalToonTokens = 0
@@ -204,9 +204,12 @@ ${detailedExamples}
</details>
`.trimStart()
console.log(`${barChartSection}\n`)
prompts.log.message(`${barChartSection}\n`)
await ensureDir(path.join(BENCHMARKS_DIR, 'results'))
const resultsDir = path.join(BENCHMARKS_DIR, 'results')
await ensureDir(resultsDir)
const outputFilePath = path.join(resultsDir, 'token-efficiency.md')
await fsp.writeFile(outputFilePath, markdown, 'utf-8')
consola.success(`Benchmark written to \`${path.relative(ROOT_DIR, outputFilePath)}\``)
prompts.log.success(`Result saved to \`${path.relative(ROOT_DIR, outputFilePath)}\``)