| 1 | #!/usr/bin/env bash
|
| 2 | #
|
| 3 | # Usage:
|
| 4 | # data_lang/pretty-benchmark.sh <function name>
|
| 5 |
|
| 6 | set -o nounset
|
| 7 | set -o pipefail
|
| 8 | set -o errexit
|
| 9 |
|
| 10 | # Only show real time
|
| 11 | TIMEFORMAT='%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 |
|
| 26 | compare() {
|
| 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 | float-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 | bin/ysh -c '
|
| 52 | var L = []
|
| 53 | for i in (1 .. 200) {
|
| 54 | call L->append(i/3)
|
| 55 | }
|
| 56 | = L
|
| 57 | '
|
| 58 | }
|
| 59 |
|
| 60 | "$@"
|