Work with agents / Local workspaces
Measure workspaces on your repository
You work on src itself, and you want to compare workspaces with git worktrees on a real repository. A script in the TanStack Source checkout measures src ws create against git worktree add with an install, and prints the times and the disk space of both.
3 min read
You need a checkout of TanStack Source, and the repository that you want to measure.
1. Build src
In the checkout of TanStack Source, run:
pnpm -C packages/cli build
2. Run the script
Give it the path of your repository, here ../app:
node --experimental-strip-types packages/cli/scripts/ws-bench.ts ../app --out bench.json
It prints a table, and writes the JSON to the file of --out. These flags change a run:
| Flag | What it does |
|---|---|
--runs <n> | Gives the median of more runs. |
--command <cmd> | Replaces the first commands. |
--install <cmd> | Replaces the install of the worktree. |
Done
You have the times and the disk space of both sides on your repository, in the table and in bench.json.
The script removes its worktrees and closes its workspaces at the end. The prepared base, the checkpoints and the folders in the pool stay, as after other src ws commands.
What the script measures
The script first warms up both sides: one worktree with an install fills the store of your package manager, and src ws prepare makes the layers. It measures src twice:
- With a ready pool:
createtakes a ready workspace, andclosekeeps the folder as a spare. - With the pool off:
createbuilds a new folder, andclosedeletes it.
For each side, it measures:
- The time to the first command: the create, the install, then
git statusand thetypecheck,lintortestscript ofpackage.json. - The drop of free space on the drive, which is the physical space. Other programs that write to the drive change it too.
- The size of the files, as each file reports it. A clone counts in full here.
- The time of a checkpoint after one edit:
git stash createfor the worktree,src ws checkpointfor the workspace. - The time of the cleanup:
git worktree removeagainstsrc ws close.
It does not measure the use of memory or CPU of idle workspaces.
One result
This is one result, on a Windows 11 computer with a plain NTFS drive and no copy-on-write. The repository is TanStack Source itself (2,279 files, pnpm 11.1.1), and each number is the median of 3 runs:
git worktree add and pnpm install | src ws create, ready pool | |
|---|---|---|
| Time of the create | 10.8 s | 1.1 s |
| Time to the first command | 12.1 s | 2.5 s |
| Time of the cleanup | 9.5 s | 0.9 s |
| Time of a checkpoint | 0.2 s | 0.9 s |
| Drop of free disk space | 59.2 MiB | 0.1 MiB |
Your numbers depend on your disk, your package manager and the size of your repository.