Skip to content

Commit bf8a365

Browse files
committed
Compared bincode against CBOR
1 parent f2640c0 commit bf8a365

File tree

8 files changed

+2248
-0
lines changed

8 files changed

+2248
-0
lines changed

scripts/bytecode-sizes/bincode-vs-cbor.jsonl

Lines changed: 727 additions & 0 deletions
Large diffs are not rendered by default.
24.5 KB
Loading

scripts/bytecode-sizes/bincode.jsonl

Lines changed: 727 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set term png size 1200,800;
2+
set output FILEOUT;
3+
unset key;
4+
set title NAME;
5+
set logscale x;
6+
set xlabel "Base Bytecode Size (Log)";
7+
set ylabel "Alt Bytecode Ratio";
8+
9+
plot FILEIN using 2:4 with points;

scripts/bytecode-sizes/cbor.jsonl

Lines changed: 727 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
IN1=$1
5+
IN2=$2
6+
7+
jq --slurp -c '
8+
. as $top |
9+
($top[] | select(.encoding == "base") | .data[]) as $base |
10+
($top[] | select(.encoding == "alt") | .data[] | select(.name == $base.name)) as $alt |
11+
{
12+
name: $base.name,
13+
base_size: $base.bytecode_size,
14+
alt_size: $alt.bytecode_size,
15+
ratio: ($alt.bytecode_size / $base.bytecode_size)
16+
}
17+
' \
18+
<(cat $IN1 | jq --slurp '{encoding: "base", data: .}') \
19+
<(cat $IN2 | jq --slurp '{encoding: "alt", data: .}') \
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
IN=$1
5+
NAME=$(basename $IN .jsonl)
6+
DAT=$(dirname $IN)/$NAME.dat
7+
PNG=$(dirname $IN)/$NAME.png
8+
PLT=$(dirname $0)/bytecode-size-scatter.plt
9+
10+
cat $IN | jq -r '[.name, .base_size, .alt_size, .ratio] | @tsv' > $DAT
11+
12+
gnuplot \
13+
-e "NAME='$(echo $NAME | tr _ - )'" \
14+
-e "FILEIN='$DAT'" \
15+
-e "FILEOUT='$PNG'" \
16+
$PLT
17+
18+
rm $DAT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
OUT=${1:-bytecode-size.jsonl}
5+
rm -f $OUT
6+
7+
for file in aztec-packages/noir-projects/noir-protocol-circuits/target/*.json; do
8+
PROGRAM=$(basename $file .json)
9+
cat $file \
10+
| jq --arg PROGRAM $PROGRAM \
11+
-c '{name: $PROGRAM, bytecode_size: .bytecode | @base64d | length}' \
12+
>> $OUT
13+
done
14+
15+
for file in aztec-packages/noir-projects/noir-contracts/target/*.json; do
16+
CONTRACT=$(basename $file .json)
17+
cat $file \
18+
| jq --arg CONTRACT $CONTRACT \
19+
-c '.functions | sort_by(.name) | .[] | {name: ($CONTRACT + "::" + .name), "bytecode_size": .bytecode | @base64d | length}' \
20+
>> $OUT
21+
done

0 commit comments

Comments
 (0)