From f34e36491a1b2c67e4f2680d13e5ab529c7f3d6a Mon Sep 17 00:00:00 2001 From: Andy C Date: Sun, 17 Nov 2024 00:49:13 -0500 Subject: [PATCH] [benchmarks/callgrind] Add YSH json workload Using the test case from issue #2123 --- benchmarks/callgrind.sh | 25 +++++++++++++++++-------- test/bug-2123.ysh | 6 +++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/benchmarks/callgrind.sh b/benchmarks/callgrind.sh index c2bc3f3606..5ac8993753 100755 --- a/benchmarks/callgrind.sh +++ b/benchmarks/callgrind.sh @@ -8,25 +8,34 @@ set -o pipefail set -o errexit build-and-run() { - # Hm dbg build seems to give more exact info - local osh=_bin/cxx-dbg/osh - #local osh=_bin/cxx-opt/osh + local sh=$1 + shift + ninja $sh + valgrind --tool=callgrind $sh "$@" +} - ninja $osh +osh-run() { + build-and-run _bin/cxx-dbg/osh "$@" +} - valgrind --tool=callgrind \ - $osh "$@" +ysh-run() { + build-and-run _bin/cxx-dbg/ysh "$@" } fib() { - build-and-run benchmarks/compute/fib.sh 10 44 + osh-run benchmarks/compute/fib.sh 10 44 } parse-cpython-configure() { # Goal: eliminate string slicing in this workload! It should just be # creating fixed size Tokens, syntax.asdl nodes, and List - build-and-run -n --ast-format none Python-2.7.13/configure + ysh-run -n --ast-format none Python-2.7.13/configure +} + +json() { + # 50 lines + ysh-run test/bug-2123.ysh 50 } with-callgrind() { diff --git a/test/bug-2123.ysh b/test/bug-2123.ysh index a007bf8b62..2666b2a497 100644 --- a/test/bug-2123.ysh +++ b/test/bug-2123.ysh @@ -23,7 +23,11 @@ proc filter-continue (; predicate) { var f = '_tmp/b1' -for i in (0 ..= 100_000) { +# Using YSH numbers +var lines = ${1:-100_000} + +for i in (0 ..= lines) { + json write ({}, space=0) } > $f