-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
PROFILER=../../../noir/noir-repo/target/debug/noir-profiler | ||
|
||
if [ ! -f $PROFILER ]; then | ||
echo "Profiler not found, building profiler" | ||
cd ../../../noir/noir-repo/tooling/profiler | ||
cargo build | ||
cd - | ||
fi | ||
|
||
# first console arg is contract name in camel case (e.g. TokenBridge) | ||
CONTRACT=$1 | ||
|
||
# second console arg is the contract function | ||
FUNCTION=$2 | ||
|
||
# convert contract name to following format: token_bridge_contract-TokenBridge.json | ||
ARTIFACT=$(echo "$CONTRACT" | sed -r 's/^([A-Z])/\L\1/; s/([a-z0-9])([A-Z])/\1_\L\2/g') | ||
ARTIFACT_NAME="${ARTIFACT}_contract-${CONTRACT}" | ||
|
||
# Extract artifact for the specific function | ||
node ../extractFunctionAsNoirArtifact.js "../target/${ARTIFACT_NAME}.json" $FUNCTION | ||
|
||
FUNCTION_ARTIFACT="${ARTIFACT_NAME}-${FUNCTION}.json" | ||
|
||
# Make flamegraph directory in ../target | ||
mkdir -p ../target/flamegraph | ||
|
||
# At last, generate the flamegraph | ||
$PROFILER gates-flamegraph --artifact-path ../target/$FUNCTION_ARTIFACT --backend-path ../../../barretenberg/cpp/build/bin/bb --output ../target/flamegraph | ||
|
||
# serve the file over http | ||
echo "Serving flamegraph at http://0.0.0.0:8000/main.svg" | ||
python3 -m http.server --directory ../target/flamegraph 8000 |