OILS / data_lang / pretty-benchmark.sh View on Github | oilshell.org

45 lines, 16 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# data_lang/pretty-benchmark.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10# Only show real time
11TIMEFORMAT='%R'
12# User time is also interesting
13# TIMEFORMAT='%U'
14
15# It takes much longer to print than to parse.
16#
17# Output example:
18#
19# benchmarks/testdata/configure-coreutils - parsing only, then parsing and printing
20# AST not printed.
21# 0.129
22#
23# 108811544 # <-- This is 109 MB of output text!
24# 3.679
25
26compare() {
27 local osh=_bin/cxx-opt/osh
28 ninja $osh
29
30 for file in benchmarks/testdata/*; do
31 echo ---
32 echo "$file - parsing only, then parsing and printing"
33
34 # Don't print at all. configure-coreutils is 136 ms.
35 time $osh --ast-format none --tool syntax-tree $file
36 echo
37
38 # Print the whole thing
39 time $osh --ast-format text --tool syntax-tree $file | wc --bytes
40 echo
41
42 done
43}
44
45"$@"