# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1680233089 -7200
#      Fri Mar 31 05:24:49 2023 +0200
# Node ID 3674705944b61138ffe657ed11eb02b078486078
# Parent  5f01c23e26e62b132b48cae8f1eb9977fe9396c3
benchmark: add a benchmark for `hg cat`

There is pathological performance around pattern matching that can cripple the
command.

diff --git a/suites/hg/benchmarks/cat.pbd b/suites/hg/benchmarks/cat.pbd
new file mode 100644
--- /dev/null
+++ b/suites/hg/benchmarks/cat.pbd
@@ -0,0 +1,54 @@
+[meta]
+format="0"
+name="cat"
+method="simple-command"
+
+[run]
+copy-data-env = true
+
+[simple-command]
+command='hg cat $REV "$FILES" $TEMPLATE > /dev/null'
+cwd="DATA-VARS:mercurial.main-repo-path"
+prepare-run = """
+# XXX We could only do this once before the benchmark instead of doing this for
+# each run, especially the one who do not need them.
+
+hg files $REV --template 'path:{path}\n' | sort > ../all_sorted.path;
+
+shuf ../all_sorted.path --random-source=../all_sorted.path > ../all_suffled.path;
+
+hg files $REV | sed 's/\\({\\|}\\|\\[\\|\\]\\|*\\|?\\)/\\\\\\1/g' | sort > ../all_sorted.pattern;
+
+shuf ../all_sorted.pattern --random-source=../all_sorted.pattern > ../all_suffled.pattern;
+"""
+
+[simple-command.variants.dimensions.rev.tip]
+default=true
+environment.REV="--rev tip"
+
+[simple-command.variants.dimensions.output.plain]
+default=true
+environment.TEMPLATE=""
+
+[simple-command.variants.dimensions.output.json]
+environment.TEMPLATE="--template json"
+
+
+[simple-command.variants.dimensions.files.all-root]
+default=true
+environment.FILES="."
+
+[simple-command.variants.dimensions.files.all-glob]
+environment.FILES="set:**"
+
+[simple-command.variants.dimensions.files.all-list-path-sorted]
+environment.FILES='set:listfile:../all_sorted.path'
+
+[simple-command.variants.dimensions.files.all-list-path-shuffled]
+environment.FILES='set:listfile:../all_suffled.path'
+
+[simple-command.variants.dimensions.files.all-list-pattern-sorted]
+environment.FILES='set:listfile:../all_sorted.pattern'
+
+[simple-command.variants.dimensions.files.all-list-pattern-shuffled]
+environment.FILES='set:listfile:../all_suffled.pattern'