Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(bench): give each app its own arguments and run Zed

rokartur26f338069319
diff --git a/port/tools/bench b/port/tools/bench
index 231838f9486..b9b52b3a5ce 100755
--- a/port/tools/bench
+++ b/port/tools/bench
@@ -17,10 +17,13 @@
# Prints one TSV row per app and metric: the median and the samples.
#
# APPS="name1=command1;name2=command2" FOLDER=<dir> port/tools/bench
-# Each command gets --disable-workspace-trust --user-data-dir <dir> --extensions-dir <dir> <FOLDER> appended; the
-# command must exec the app's binary (the process that owns its windows). SETTINGS (a JSON object) becomes every
-# app's user settings.json. RUNS (5), IDLE_FROM (60) and IDLE_SECONDS (30) override the defaults. COLD=1 empties the
-# file cache with `sudo -n purge` before every run (needs passwordless sudo for purge); by default the cache stays warm.
+# A command runs with BENCH_DATA (its app's own folder, kept for all its runs) and FOLDER in the environment, and
+# must exec the app's binary (the process that owns its windows). A command that names $FOLDER passes its own
+# arguments (Zed: port/tools/bench-zed "$BENCH_DATA" "$FOLDER"); any other gets VS Code's appended:
+# --disable-workspace-trust --user-data-dir <BENCH_DATA>/user-data --extensions-dir <BENCH_DATA>/extensions <FOLDER>,
+# and SETTINGS (a JSON object) as its user settings.json. RUNS (5), IDLE_FROM (60) and IDLE_SECONDS (30) override the
+# defaults. COLD=1 empties the file cache with `sudo -n purge` before every run (needs passwordless sudo for purge); by
+# default the cache stays warm.
set -euo pipefail
source "$(dirname "$0")/gui-lock.sh"
@@ -68,7 +71,9 @@ measure_once() {
local command=$1 dir=$2 start pid sampler shown ready cpu before after memory p mib exthost=0 pids quit_start quit
[[ -z ${COLD:-} ]] || sudo -n purge
start=$(now)
- bash -c "exec $command --disable-workspace-trust --user-data-dir '$dir/user-data' --extensions-dir '$dir/extensions' '$FOLDER'" >/dev/null 2>&1 &
+ [[ $command == *'$FOLDER'* ]] ||
+ command+=" --disable-workspace-trust --user-data-dir '$dir/user-data' --extensions-dir '$dir/extensions' '$FOLDER'"
+ BENCH_DATA=$dir FOLDER=$FOLDER bash -c "exec $command" >/dev/null 2>&1 &
pid=$!
"$scratch/bench-memory" watch "$pid" > "$dir/memory" &
sampler=$!
diff --git a/port/tools/bench-zed b/port/tools/bench-zed
new file mode 100755
index 00000000000..c9536d0e95e
--- /dev/null
+++ b/port/tools/bench-zed
@@ -0,0 +1,7 @@
+#!/bin/bash
+# Zed's command for port/tools/bench: port/tools/bench-zed <data dir> <folder>. Zed 1.30 reads its settings from
+# <data dir>/config with --user-data-dir. AI off as VS Code's chat.disableAIFeatures, no update check, no telemetry.
+set -euo pipefail
+mkdir -p "$1/config"
+echo '{"disable_ai": true, "auto_update": false, "telemetry": {"diagnostics": false, "metrics": false}}' > "$1/config/settings.json"
+exec "${ZED:-/Applications/Zed.app/Contents/MacOS/zed}" --user-data-dir "$1" "$2"