Skip to content

Commit

Permalink
Add elapsed time for each test to static page
Browse files Browse the repository at this point in the history
  • Loading branch information
dsocolobsky committed Dec 5, 2024
1 parent 29d50a4 commit 063c9d7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
19 changes: 13 additions & 6 deletions .github/scripts/flamegraph.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash

iterations=3
iterations=10
value=10000000
account=0x33c6b73432B3aeA0C1725E415CC40D04908B85fd
end_val=$((172 * $iterations * $value))

echo "Sending to account $account"
ethrex_l2 test load --path ./test_data/private_keys.txt -i $iterations -v --value $value --to $account
ethrex_l2 test load --path /home/runner/work/ethrex/ethrex/test_data/private_keys.txt -i $iterations -v --value $value --to $account

echo "Waiting for transactions to be processed..."
start_time=$(date +%s)
output=$(cast balance $account --rpc-url=http://localhost:1729 2>&1)
retries=0
while [[ $output -le $end_val && $retries -lt 30 ]]; do
Expand All @@ -17,6 +16,14 @@ while [[ $output -le $end_val && $retries -lt 30 ]]; do
echo "balance was $output still not reached value of $end_val (retry $retries/30)"
((retries++))
done
echo "Done. Balance of $output reached, killing process ethrex"
end_time=$(date +%s)
elapsed_time=$((end_time - start_time))
minutes=$((elapsed_time / 60))
seconds=$((elapsed_time % 60))
echo "Balance of $output reached in $minutes min $seconds s, killing process ethrex"

sudo pkill ethrex && while pgrep -l "cargo-flamegraph"; do echo "waiting for reth to exit... "; sleep 1;done;
echo "ethrex killed"

# We need this for the following job, to add to the static page
echo "minutes=$minutes" >> "$GITHUB_OUTPUT"
echo "seconds=$seconds" >> "$GITHUB_OUTPUT"
14 changes: 11 additions & 3 deletions .github/scripts/flamegraph_reth.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

iterations=3
iterations=10
value=10000000
account=0x33c6b73432B3aeA0C1725E415CC40D04908B85fd
end_val=$((172 * $iterations * $value))

ethrex_l2 test load --path /home/runner/work/ethrex/ethrex/test_data/private_keys.txt -i $iterations -v --value $value --to $account

echo "Monitoring..."
start_time=$(date +%s)
output=$(cast balance $account --rpc-url=http://localhost:1729 2>&1)
retries=0
while [[ $output -le $end_val && $retries -lt 30 ]]; do
Expand All @@ -16,6 +16,14 @@ while [[ $output -le $end_val && $retries -lt 30 ]]; do
echo "balance was $output still not reached value of $end_val (retry $retries/30)"
((retries++))
done
echo "Balance of $output reached, killing process reth"
end_time=$(date +%s)
elapsed_time=$((end_time - start_time))
minutes=$((elapsed_time / 60))
seconds=$((elapsed_time % 60))
echo "Balance of $output reached in $minutes min $seconds s, killing process reth"

sudo pkill reth && while pgrep -l "cargo-flamegraph"; do echo "waiting for reth to exit... "; sleep 1;done;

# We need this for the following job, to add to the static page
echo "minutes=$minutes" >> "$GITHUB_OUTPUT"
echo "seconds=$seconds" >> "$GITHUB_OUTPUT"
14 changes: 13 additions & 1 deletion .github/workflows/flamegraph_reporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
flamegraph:
name: Generate Flamegraph for load test
runs-on: ubuntu-latest
outputs:
minutes: ${{steps.generate-flamegraph.outputs.minutes}}
seconds: ${{steps.generate-flamegraph.outputs.seconds}}
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -54,7 +57,8 @@ jobs:
- name: Build ethrex
run: CARGO_PROFILE_RELEASE_DEBUG=true cargo build --release --bin ethrex --features dev

- name: Generate Flamegraph data for Ethrex
- id: generate-flamegraph
name: Generate Flamegraph data for Ethrex
shell: bash
run: |
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -c "record -o perf.data -F997 --call-graph dwarf,16384 -g" --bin ethrex --features dev -- --network test_data/genesis-l2.json --http.port 1729 &
Expand Down Expand Up @@ -82,6 +86,9 @@ jobs:
flamegraph-reth:
name: Generate Flamegraph for Reth
runs-on: ubuntu-latest
outputs:
minutes: ${{steps.generate-flamegraph.outputs.minutes}}

Check failure on line 90 in .github/workflows/flamegraph_reporter.yaml

View workflow job for this annotation

GitHub Actions / Lint

property "generate-flamegraph" is not defined in object type {}
seconds: ${{steps.generate-flamegraph.outputs.seconds}}

Check failure on line 91 in .github/workflows/flamegraph_reporter.yaml

View workflow job for this annotation

GitHub Actions / Lint

property "generate-flamegraph" is not defined in object type {}
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -185,7 +192,12 @@ jobs:
cp -r flamegraph_reth.svg pages/
ls -las pages/
date +'%Y-%m-%dT%H:%M:%S'
echo ${{ needs.flamegraph.outputs.minutes }}
sed -i "s/{{LAST_UPDATE}}/$(date +'%Y-%m-%dT%H:%M:%S')/g" pages/index.html
sed -i "s/{{ETHREX_MIN}}/${{ needs.flamegraph.outputs.minutes }}/g" pages/index.html
sed -i "s/{{ETHREX_SEC}}/${{ needs.flamegraph.outputs.seconds }}/g" pages/index.html
sed -i "s/{{RETH_MIN}}/${{ needs.flamegraph-reth.outputs.minutes }}/g" pages/index.html
sed -i "s/{{RETH_SEC}}/${{ needs.flamegraph-reth.outputs.minutes }}/g" pages/index.html
- name: Setup Pages
uses: actions/configure-pages@v5
Expand Down
6 changes: 4 additions & 2 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ <h2>Ethrex</h2>
<a href="flamegraph_ethrex.svg/flamegraph_ethrex.svg"
download="flamegraph_ethrex.svg/flamegraph_ethrex.svg">Download</a>
</div>
<object id="svg1" data="flamegraph_ethrex.svg/flamegraph_ethrex.svg" type="image/svg+xml" width=90%
<p class="time-elapsed">Time elapsed: {{ETHREX_MIN}}min {{ETHREX_SEC}}s</p>
<object id="svg1" data="flamegraph_ethrex.svg/flamegraph_ethrex.svg" type="image/svg+xml" width=100%
height=90%"></object>
</div>
<div class="column">
<div class="col-header">
<h2>Reth</h2>
<a href="flamegraph_reth.svg/flamegraph_reth.svg" download="flamegraph_reth.svg/flamegraph_reth.svg">Download</a>
</div>
<object id="svg2" data="flamegraph_reth.svg/flamegraph_reth.svg" type="image/svg+xml" width=90%
<p class="time-elapsed">Time elapsed: {{RETH_MIN}}min {{RETH_SEC}}s</p>
<object id="svg2" data="flamegraph_reth.svg/flamegraph_reth.svg" type="image/svg+xml" width=100%
height=90%></object>
</div>
</main>
Expand Down
7 changes: 6 additions & 1 deletion pages/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ img {
width: 80%;
height: auto;
max-width: 200px;
max-height: 150px; /* Prevent SVGs from being too tall */
max-height: 150px;
}

h2 {
Expand All @@ -60,3 +60,8 @@ h2 {
.col-header {
margin-bottom: 2em;
}

.time-elapsed {
font-size: 0.9em;
margin-bottom: 0.8em;
}

0 comments on commit 063c9d7

Please sign in to comment.