| 1 | #!/usr/bin/env bash
 | 
| 2 | #
 | 
| 3 | # Usage:
 | 
| 4 | #   opy/demo.sh <function name>
 | 
| 5 | 
 | 
| 6 | set -o nounset
 | 
| 7 | set -o pipefail
 | 
| 8 | set -o errexit
 | 
| 9 | 
 | 
| 10 | readonly THIS_DIR=$(cd $(dirname $0) && pwd)
 | 
| 11 | 
 | 
| 12 | osh-byterun() {
 | 
| 13 |   opy/_tmp/repo-with-opy/bin/osh-byterun "$@"
 | 
| 14 | }
 | 
| 15 | 
 | 
| 16 | # Show the difference between OSH running under CPython and OSH running under
 | 
| 17 | # byterun.
 | 
| 18 | osh-byterun-speed() {
 | 
| 19 |   pushd $THIS_DIR/..
 | 
| 20 | 
 | 
| 21 |   local prog='for i in $(seq 10); do echo $i; done'
 | 
| 22 |   time bin/osh -c "$prog"
 | 
| 23 |   time osh-byterun -c "$prog"
 | 
| 24 | 
 | 
| 25 |   popd
 | 
| 26 | }
 | 
| 27 | 
 | 
| 28 | osh-byterun-parse() {
 | 
| 29 |   local prog='echo "hello world"'
 | 
| 30 | 
 | 
| 31 |   pushd $THIS_DIR/..
 | 
| 32 |   time bin/osh -n -c "$prog"
 | 
| 33 |   time osh-byterun -n -c "$prog"
 | 
| 34 |   popd
 | 
| 35 | }
 | 
| 36 | 
 | 
| 37 | resolve() {
 | 
| 38 |   PYTHONPATH=. RESOLVE=1 bin/oil.py
 | 
| 39 | }
 | 
| 40 | 
 | 
| 41 | "$@"
 |