diff --git a/docs/benchmarks/performance/README.md b/docs/benchmarks/performance/README.md index b6fc3b6316..c7e783c1b9 100644 --- a/docs/benchmarks/performance/README.md +++ b/docs/benchmarks/performance/README.md @@ -7,7 +7,7 @@ the on-disk and one-turn tables there came from other means, and `METHOD-REVIEW. records what is and is not documented about them. ```bash -WORKDIR=$PWD docs/benchmarks/measure-cli.sh codeaf /tmp/bench-home/codeaf ./bin/codeaf chat +WORKDIR=$PWD docs/benchmarks/performance/measure-cli.sh codeaf /tmp/bench-home/codeaf ./bin/codeaf chat ``` Run it once per CLI, on the same machine, in the same working directory, within the same diff --git a/docs/benchmarks/performance/doc_paths_test.go b/docs/benchmarks/performance/doc_paths_test.go new file mode 100644 index 0000000000..51f91d5a12 --- /dev/null +++ b/docs/benchmarks/performance/doc_paths_test.go @@ -0,0 +1,40 @@ +package performance_test + +import ( + "os" + "path/filepath" + "regexp" + "runtime" + "testing" +) + +var localScriptExample = regexp.MustCompile(`(?:docs|scripts)/[A-Za-z0-9_./-]+\.sh`) + +func TestDocumentedScriptPathsResolve(t *testing.T) { + _, source, _, ok := runtime.Caller(0) + if !ok { + t.Fatal("could not locate test source") + } + root := filepath.Clean(filepath.Join(filepath.Dir(source), "..", "..", "..")) + + for _, document := range []string{"README.md", "measure-cli.sh"} { + t.Run(document, func(t *testing.T) { + path := filepath.Join(root, "docs", "benchmarks", "performance", document) + contents, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + matches := localScriptExample.FindAllString(string(contents), -1) + if len(matches) == 0 { + t.Fatal("no local script examples found") + } + + for _, example := range matches { + scriptPath := filepath.Join(root, filepath.FromSlash(example)) + if _, err := os.Stat(scriptPath); err != nil { + t.Errorf("documented script %q does not resolve: %v", example, err) + } + } + }) + } +} diff --git a/docs/benchmarks/performance/measure-cli.sh b/docs/benchmarks/performance/measure-cli.sh index 3a26cb5688..16c6529f1f 100755 --- a/docs/benchmarks/performance/measure-cli.sh +++ b/docs/benchmarks/performance/measure-cli.sh @@ -5,7 +5,7 @@ # # From the root of a real repository: # -# WORKDIR=$PWD docs/benchmarks/measure-cli.sh mine /tmp/bench-home/mine bin/mine chat +# WORKDIR=$PWD docs/benchmarks/performance/measure-cli.sh mine /tmp/bench-home/mine bin/mine chat # # only labels the output, the tmux session and the run; nothing about the # CLI is inferred from it. is the profile the CLI runs under — an diff --git a/docs/changes/unreleased/1498-measure-cli-path.md b/docs/changes/unreleased/1498-measure-cli-path.md new file mode 100644 index 0000000000..e63715cc20 --- /dev/null +++ b/docs/changes/unreleased/1498-measure-cli-path.md @@ -0,0 +1,15 @@ +--- +kind: fixed +title: benchmark examples use the script's current path +pr: 1498 +# Optional. Which part of the repository this touches, so a reader can skip it. +# One or more of: build, chat, docs, engine, remote, resident +surface: [docs] +# Optional, and the reason this file exists. Every statement that WAS true and is +# not any more, written whole: what it was, and what it is now. A model reading +# this has to be able to check its own memory against it, so "branch names" is +# useless and "the trunk was chat-v3-task and no longer exists; work goes to dev" +# is the whole point. Leave the list empty if nothing anybody believed changed. +invalidates: + - "The examples pointed to `docs/benchmarks/measure-cli.sh`, which does not exist; use `docs/benchmarks/performance/measure-cli.sh`." +---