Skip to content

Commit

Permalink
[benchmarks/callgrind] Add YSH json workload
Browse files Browse the repository at this point in the history
Using the test case from issue #2123
  • Loading branch information
Andy C committed Nov 17, 2024
1 parent 5bcc9f6 commit f34e364
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
25 changes: 17 additions & 8 deletions benchmarks/callgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>

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() {
Expand Down
6 changes: 5 additions & 1 deletion test/bug-2123.ysh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f34e364

Please sign in to comment.