# Benchmarks

Three ways to pack the same repository, measured on this repository itself. The numbers are generated
by [`scripts/benchmark.mjs`](https://github.com/ankurhalder/codebase-snapshot/blob/main/scripts/benchmark.mjs), which
anyone can run:

```bash
node scripts/benchmark.mjs /path/to/repo "the question to slice for"
```

The run below used the default question, on this repository at **0.21.0 on 2026-11-30**: 221 files,
764,225 estimated tokens in full.

| Mode | Files | Parts | Tokens | vs full | Time |
| :-- | --: | --: | --: | --: | --: |
| full | 221 | 9 | 764,225 | 100% | 2.05 s |
| slice | 7 | 1 | 63,983 | 8.4% | 1.68 s |
| budget (30,000) | 22 | 1 | 36,005 | 4.7% | 1.69 s |

## What the columns mean

- **Files** — entries in `manifest.files`, i.e. what the parts actually carry.
- **Parts** — part files written. A budget/slice snapshot tends to be one part because it fits.
- **Tokens** — `manifest.totals.estimatedTokens`, the structural estimate the product reports.
  `estimateTokens` counts word runs, punctuation and newline runs; it is neither bytes/4 nor a
  tokenizer count, and every model tokenizes differently.
- **vs full** — token share of the full snapshot.
- **Time** — wall clock for the whole `generate` process, including scan, parse, partition and write.

## What to take from it

1. **The full snapshot is usually too large to paste.** Under a million tokens for this repository is
   typical for a mature codebase; a 200k-token window cannot hold it.
2. **A slice is two orders of magnitude smaller and still coherent**: four files that the planner
   judged relevant, with their bodies intact.
3. **A budget is the "fit the window" answer**: 21 whole files at 3.7% of the tokens, chosen by entry
   point, importer count and layer rather than by alphabetical order.
4. **Generation is not the bottleneck.** All three modes take about the same time; the saving is in
   what gets written, not in what gets read.

## Ten public repositories

```bash
node scripts/benchmark-suite.mjs              # the ten default repositories
node scripts/benchmark-suite.mjs --json       # the same run, as data
node scripts/benchmark-suite.mjs <url> ...    # your own list
```

Each repository is cloned shallow into a scratch directory, packed by all three tools, and the
clone is deleted. A repository that cannot be cloned is reported as skipped with the reason, never
dropped from the table. Measured at **0.21.0 on 2026-11-30**, with repomix 1.19.0 and gitingest from
PyPI. The shape held; small file-count differences are policy (notably bounded previews), not
scanner drift.

| Repository | Ours files | Ours tokens | repomix tokens | repomix / ours | gitingest bytes |
| :-- | --: | --: | --: | --: | --: |
| jonschlinkert/is-odd | 11 | 5,447 | 4,291 | 0.79 | 29,392 |
| chalk/chalk | 32 | 77,684 | 79,006 | 1.02 | 238,864 |
| tj/co | 19 | 12,996 | 9,189 | 0.71 | 74,613 |
| isaacs/minimatch | 87 | 303,508 | 64,794,947 | 213.49 | 1,764,476 |
| moment/luxon | 151 | 303,029 | 250,093 | 0.83 | 806,740 |
| psf/requests | 117 | 382,695 | 687,333 | 1.80 | 524,712 |
| pallets/click | 177 | 470,265 | 335,153 | 0.71 | 1,413,342 |
| expressjs/express | 215 | 261,817 | 198,639 | 0.76 | 792,177 |
| colinhacks/zod | 687 | 1,768,759 | 1,752,965 | 0.99 | 4,485,971 |
| anuraghazra/github-readme-stats | 131 | 205,013 | 169,079 | 0.82 | 553,367 |

Read it carefully:

- **The ratio is not a contest.** Our manifest estimate weighs word runs, punctuation and
  newlines; the byte-based budget planner uses one token per four bytes; repomix uses a tokenizer.
  Across nine repositories the two land within about plus or minus 30%, which is what two
  reasonable estimates of the same text do.
- **minimatch is the exception, and it is a policy difference, not an estimate.** That repository
  carries five benchmark fixtures of 20 to 25 MB of JSON. repomix emits them (64.8M tokens); our
  large-file rule emits a bounded preview and records the omission, so the pack stays 303,508 tokens.
  A pack that will not fit in a context window has not helped the reader, however complete it is.
- **gitingest publishes no token count**, so its column is the size of its one-document digest.
- **File counts agree within one or two** everywhere except minimatch, where our preview keeps the
  files and repomix keeps their bytes.

The point of ten repositories is not a leaderboard; it is that the shape holds outside the
repository the tool was written in.

## Honest limits

- Self-benchmark. This repository is TypeScript with a clean import graph; a vendored monorepo with
  a thousand dependencies will score differently, and a repository with no imports at all gives the
  planner little to rank.
- One machine, one run. The times are indicative, not a controlled benchmark; the token counts are
  deterministic for a fixed repository and configuration.
- These are **our** modes. The head-to-head is below, with both tools' own accounting.

## Head-to-head against repomix

```bash
node scripts/compare.mjs --repomix      # add --json for machine-readable output
```

repomix is fetched through `npx` at run time and gitingest through `python -m gitingest`;
neither is a dependency of this package. Measured on this repository at **0.21.0 on 2026-11-30**,
repomix 1.19.0, gitingest from PyPI, same machine:

| Tool / mode | Files | Content bytes | Tokens | vs full | Time |
| :-- | --: | --: | --: | --: | --: |
| codebase-snapshot (full) | 221 | 2,549,431 | 764,225 | 100% | 2.04 s |
| codebase-snapshot (slice) | 7 | 231,622 | 63,983 | 8.4% | 1.63 s |
| codebase-snapshot (budget 30,000) | 22 | 119,794 | 36,005 | 4.7% | 1.70 s |
| repomix 1.19.0 | 386 | 4,245,226 | 1,067,915 | 139.7% | n/a |
| gitingest | ? | 3,848,714 | n/a | n/a | n/a |

Read that honestly:

- **The comparison is not a purity test.** repomix packed 386 files and 4.25 MB; our full run packed
  221 files and 2.55 MB. The file sets differ because the ignore rules differ, so the token totals
  describe two different packs.
- **Each tool counts tokens its own way.** Our manifest counts word runs, punctuation and newlines
  (the budget planner uses bytes/4); repomix uses a tokenizer. Neither is the model's exact count;
  read the share, not the absolute number.
- **Our pack is smaller in bytes** (2.55 MB of file content against repomix's 4.25 MB of output,
  which includes its own wrappers), and gitingest's digest is larger still at 3.85 MB.
- **The modes are what the other tool does not have.** repomix packs the repository; a slice and a
  budget are the same snapshot narrowed after scanning, at 8.4% and 4.7% of our full tokens.
- **gitingest publishes no token count at all.** The harness reports its digest size and says so.
  Its output is one flat document with a tree and a separator per file, which is why a byte
  comparison is the only honest one.

The same caveats apply to any comparison: different ignore rules, different wrappers, different
tokenizers. What is comparable is the shape — full packs are too large for a context window, and a
selection is one to two orders of magnitude smaller.