Skip to content

Commit

Permalink
path independent
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Jun 18, 2024
1 parent ab11251 commit 7feef9f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions noir-projects/noir-contracts/scripts/flamegraph.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env bash
set -eu

PROFILER=../../../noir/noir-repo/target/debug/noir-profiler
# Get the directory of the script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

PROFILER="$SCRIPT_DIR/../../../noir/noir-repo/target/debug/noir-profiler"

if [ ! -f $PROFILER ]; then
echo "Profiler not found, building profiler"
cd ../../../noir/noir-repo/tooling/profiler
cd "$SCRIPT_DIR/../../../noir/noir-repo/tooling/profiler"
cargo build
cd -
cd "$SCRIPT_DIR"
fi

# first console arg is contract name in camel case (e.g. TokenBridge)
Expand All @@ -21,16 +24,16 @@ ARTIFACT=$(echo "$CONTRACT" | sed -r 's/^([A-Z])/\L\1/; s/([a-z0-9])([A-Z])/\1_\
ARTIFACT_NAME="${ARTIFACT}_contract-${CONTRACT}"

# Extract artifact for the specific function
node ../extractFunctionAsNoirArtifact.js "../target/${ARTIFACT_NAME}.json" $FUNCTION
node "$SCRIPT_DIR/../extractFunctionAsNoirArtifact.js" "$SCRIPT_DIR/../target/${ARTIFACT_NAME}.json" $FUNCTION

FUNCTION_ARTIFACT="${ARTIFACT_NAME}-${FUNCTION}.json"

# Make flamegraph directory in ../target
mkdir -p ../target/flamegraph
mkdir -p "$SCRIPT_DIR/../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
$PROFILER gates-flamegraph --artifact-path "$SCRIPT_DIR/../target/$FUNCTION_ARTIFACT" --backend-path "$SCRIPT_DIR/../../../barretenberg/cpp/build/bin/bb" --output "$SCRIPT_DIR/../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
python3 -m http.server --directory "$SCRIPT_DIR/../target/flamegraph" 8000

0 comments on commit 7feef9f

Please sign in to comment.