Skip to content
Source
Sign inSign up

Measure workspaces

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:

FlagWhat 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: create takes a ready workspace, and close keeps the folder as a spare.
  • With the pool off: create builds a new folder, and close deletes it.

For each side, it measures:

  • The time to the first command: the create, the install, then git status and the typecheck, lint or test script of package.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 create for the worktree, src ws checkpoint for the workspace.
  • The time of the cleanup: git worktree remove against src 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 installsrc ws create, ready pool
Time of the create10.8 s1.1 s
Time to the first command12.1 s2.5 s
Time of the cleanup9.5 s0.9 s
Time of a checkpoint0.2 s0.9 s
Drop of free disk space59.2 MiB0.1 MiB

Your numbers depend on your disk, your package manager and the size of your repository.