Skip to content

Commit

Permalink
Compared bincode against CBOR
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Feb 25, 2025
1 parent f2640c0 commit bf8a365
Show file tree
Hide file tree
Showing 8 changed files with 2,248 additions and 0 deletions.
727 changes: 727 additions & 0 deletions scripts/bytecode-sizes/bincode-vs-cbor.jsonl

Large diffs are not rendered by default.

Binary file added scripts/bytecode-sizes/bincode-vs-cbor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
727 changes: 727 additions & 0 deletions scripts/bytecode-sizes/bincode.jsonl

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions scripts/bytecode-sizes/bytecode-size-scatter.plt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set term png size 1200,800;
set output FILEOUT;
unset key;
set title NAME;
set logscale x;
set xlabel "Base Bytecode Size (Log)";
set ylabel "Alt Bytecode Ratio";

plot FILEIN using 2:4 with points;
727 changes: 727 additions & 0 deletions scripts/bytecode-sizes/cbor.jsonl

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions scripts/bytecode-sizes/compare-bytecode-size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -eu

IN1=$1
IN2=$2

jq --slurp -c '
. as $top |
($top[] | select(.encoding == "base") | .data[]) as $base |
($top[] | select(.encoding == "alt") | .data[] | select(.name == $base.name)) as $alt |
{
name: $base.name,
base_size: $base.bytecode_size,
alt_size: $alt.bytecode_size,
ratio: ($alt.bytecode_size / $base.bytecode_size)
}
' \
<(cat $IN1 | jq --slurp '{encoding: "base", data: .}') \
<(cat $IN2 | jq --slurp '{encoding: "alt", data: .}') \
18 changes: 18 additions & 0 deletions scripts/bytecode-sizes/plot-bytecode-size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -eu

IN=$1
NAME=$(basename $IN .jsonl)
DAT=$(dirname $IN)/$NAME.dat
PNG=$(dirname $IN)/$NAME.png
PLT=$(dirname $0)/bytecode-size-scatter.plt

cat $IN | jq -r '[.name, .base_size, .alt_size, .ratio] | @tsv' > $DAT

gnuplot \
-e "NAME='$(echo $NAME | tr _ - )'" \
-e "FILEIN='$DAT'" \
-e "FILEOUT='$PNG'" \
$PLT

rm $DAT
21 changes: 21 additions & 0 deletions scripts/bytecode-sizes/print-bytecode-size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eu

OUT=${1:-bytecode-size.jsonl}
rm -f $OUT

for file in aztec-packages/noir-projects/noir-protocol-circuits/target/*.json; do
PROGRAM=$(basename $file .json)
cat $file \
| jq --arg PROGRAM $PROGRAM \
-c '{name: $PROGRAM, bytecode_size: .bytecode | @base64d | length}' \
>> $OUT
done

for file in aztec-packages/noir-projects/noir-contracts/target/*.json; do
CONTRACT=$(basename $file .json)
cat $file \
| jq --arg CONTRACT $CONTRACT \
-c '.functions | sort_by(.name) | .[] | {name: ($CONTRACT + "::" + .name), "bytecode_size": .bytecode | @base64d | length}' \
>> $OUT
done

0 comments on commit bf8a365

Please sign in to comment.