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

65 lines, 21 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
45float-demo() {
46 ### Test of tabular floats - not a test or a benchmark right now
47
48 # Note: this could change if we change how floats are printed, e.g. strtof
49 # vs. strtod.
50
51 local ysh=_bin/cxx-asan/ysh
52 ninja $ysh
53
54 #ysh=bin/ysh
55
56 $ysh -c '
57var L = []
58for i in (1 .. 200) {
59 call L->append(i/30)
60}
61= L
62'
63}
64
65"$@"