Permalink
Please sign in to comment.
Browse files
Save a performance experiment with PyPy.
Summary: PyPy runs the OSH parser more slowly than CPython. This wasn't that surprising since it's a string-based workload. Saving it anyway.
- Loading branch information...
Showing
with
65 additions
and 4 deletions.
- 0 benchmarks/__init__.py
- +14 −0 benchmarks/fake_libc.py
- +35 −0 benchmarks/pypy.sh
- +4 −1 core/cmd_exec.py
- +4 −1 core/expr_eval.py
- +4 −1 core/glob_.py
- +4 −1 osh/bool_parse.py
No changes.
| @@ -0,0 +1,14 @@ | ||
| #!/usr/bin/python | ||
| """ | ||
| fake_libc.py | ||
| For PyPy. | ||
| """ | ||
| def regex_parse(regex_str): | ||
| return True | ||
| # This makes things fall through to the first case statement... | ||
| def fnmatch(s, to_match): | ||
| return True | ||
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Summary: PyPy is slower than CPython for parsing. (I bet it also uses more | ||
| # memory, although I didn't measure that.) | ||
| # | ||
| # I don't plan on using PyPy, but this is simple enough to save for posterity. | ||
| # | ||
| # Usage: | ||
| # ./pypy.sh <function name> | ||
| set -o nounset | ||
| set -o pipefail | ||
| set -o errexit | ||
| readonly PYPY=~/install/pypy2-v5.9.0-linux64/bin/pypy | ||
| parse-abuild() { | ||
| local vm=$1 | ||
| time $vm bin/oil.py osh -n ~/git/alpine/abuild/abuild >/dev/null | ||
| } | ||
| # ~3.5 seconds | ||
| parse-with-cpython() { | ||
| parse-abuild python | ||
| } | ||
| # ~4.8 seconds | ||
| # NOTE: We could run it in a loop to see if the JIT warms up, but that would | ||
| # only be for curiousity. Most shell processes are short-lived, so it's the | ||
| # wrong thing to optimize for. | ||
| parse-with-pypy() { | ||
| parse-abuild $PYPY | ||
| } | ||
| "$@" |
0 comments on commit
65f7b6c