Skip to content

Commit

Permalink
[release, metrics] Add a comparison between OPy and CPython.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Oct 6, 2018
1 parent 6ff1a49 commit b2ea3bc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
27 changes: 27 additions & 0 deletions benchmarks/bytecode.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,28 @@ FileSizes = function(all_deps_py, pyc_base_dir) {
py_pyc
}


CompareCol = function(ctx) {
c(nrow(ctx$frames),
nrow(ctx$names),
nrow(ctx$consts),
nrow(ctx$flags),
nrow(ctx$ops)
)
}

Compare = function(cpython_ctx, opy_ctx) {
Banner('CPYTHON vs. OPY')

data_frame(
table_name = c('frames', 'names', 'consts', 'flags', 'ops'),
cpython = CompareCol(cpython_ctx),
opy = CompareCol(opy_ctx)
) -> f1

ShowFrame('Overview', f1)
}

main = function(argv) {
action = argv[[1]]

Expand All @@ -295,6 +317,11 @@ main = function(argv) {
ctx = Load(in_dir)
Report(ctx)

} else if (action == 'compare') {
cpython_ctx = Load(argv[[2]])
opy_ctx = Load(argv[[3]])
Compare(cpython_ctx, opy_ctx)

} else if (action == 'src-bin-ratio') { # This takes different inputs
all_deps_py = argv[[2]]
pyc_base_dir = argv[[3]]
Expand Down
8 changes: 8 additions & 0 deletions benchmarks/bytecode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ metrics-opy() {
report metrics $BASE_DIR/opy
}

compare() {
report compare $BASE_DIR/cpython-dis-tables $BASE_DIR/opy-dis-tables
}

# Reads a .py / .pyc manifest and calculates the ratio of input/output file
# sizes.
src-bin-ratio() {
Expand All @@ -116,6 +120,10 @@ run-for-release() {
out=$BASE_DIR/src-bin-ratio-with-opy.txt
src-bin-ratio > $out
log "Wrote $out"

out=$BASE_DIR/overview.txt
compare > $out
log "Wrote $out"
}

# TODO:
Expand Down
1 change: 1 addition & 0 deletions doc/release-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Oil Version 0.6.pre5
- [nativedeps](metrics.wwz/line-counts/nativedeps.txt). Oil code plus A
slice of CPython.
- Bytecode Metrics
- [overview](metrics.wwz/bytecode/overview.txt) - Compare OPy vs. CPython.
- [oil-with-opy](metrics.wwz/bytecode/oil-with-opy.txt) - Oil compiled with
OPy.
- [oil-with-cpython](metrics.wwz/bytecode/oil-with-cpython.txt) - Oil
Expand Down

0 comments on commit b2ea3bc

Please sign in to comment.