mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-09 20:28:01 -05:00
test(performance): fetch before push and improve latency history (#1617)
This commit is contained in:
committed by
GitHub
parent
2114008704
commit
3d5ea1fa3c
6
.github/actions/publish_history/action.yml
vendored
6
.github/actions/publish_history/action.yml
vendored
@@ -16,6 +16,8 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
cd "$CHECKOUT_SUBFOLDER_HISTORY"
|
||||
git fetch origin "$PUBLISH_BRANCH_NAME"
|
||||
git reset --hard "origin/$PUBLISH_BRANCH_NAME"
|
||||
|
||||
mkdir -p "$PUBLISH_DIR_LATENCY_HISTORY"
|
||||
|
||||
@@ -25,8 +27,8 @@ runs:
|
||||
if git diff-index --quiet HEAD --; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
git commit -m "Update latency history CSVs"
|
||||
git push origin "$PUBLISH_BRANCH_NAME"
|
||||
fi
|
||||
|
||||
6
.github/actions/publish_plots/action.yml
vendored
6
.github/actions/publish_plots/action.yml
vendored
@@ -16,6 +16,8 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
cd $CHECKOUT_SUBFOLDER_SUBPLOTS
|
||||
git fetch origin "$PUBLISH_BRANCH_NAME"
|
||||
git reset --hard "origin/$PUBLISH_BRANCH_NAME"
|
||||
|
||||
# Remove any branch folder older than two weeks
|
||||
find $PUBLISH_DIR_PLOTS/ -mindepth 1 -maxdepth 1 -type d -mtime +14 -exec rm -rf {} +
|
||||
@@ -30,8 +32,8 @@ runs:
|
||||
if git diff-index --quiet HEAD --; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
git commit -m "Update performance plots for $BRANCH_NAME"
|
||||
git push origin $PUBLISH_BRANCH_NAME
|
||||
fi
|
||||
|
||||
@@ -41,6 +41,10 @@ def parse_latency_csv(csv_files):
|
||||
|
||||
|
||||
def plot_latency_history(pr_numbers, scenario_data, output_path):
|
||||
if not pr_numbers or not scenario_data:
|
||||
print("No PR latency data found; skipping plot generation.")
|
||||
return
|
||||
|
||||
num_scenarios = len(scenario_data)
|
||||
fig, axes = plt.subplots(num_scenarios, 1, figsize=(14, 4 * num_scenarios), sharex=True)
|
||||
if num_scenarios == 1:
|
||||
@@ -48,6 +52,8 @@ def plot_latency_history(pr_numbers, scenario_data, output_path):
|
||||
|
||||
color_map = plt.colormaps.get_cmap("tab10")
|
||||
|
||||
x_positions = list(range(len(pr_numbers)))
|
||||
|
||||
for i, (scenario, pr_stats) in enumerate(scenario_data.items()):
|
||||
ax = axes[i]
|
||||
min_vals = [pr_stats.get(pr, {"min": None})["min"] for pr in pr_numbers]
|
||||
@@ -57,14 +63,14 @@ def plot_latency_history(pr_numbers, scenario_data, output_path):
|
||||
color = color_map(i % color_map.N)
|
||||
|
||||
if any(v is not None for v in avg_vals):
|
||||
ax.plot(pr_numbers, avg_vals, marker="o", label="Avg Latency (ms)", color=color)
|
||||
ax.fill_between(pr_numbers, min_vals, max_vals, color=color, alpha=0.2, label="Min-Max Latency (ms)")
|
||||
for pr, avg, minv, maxv in zip(pr_numbers, avg_vals, min_vals, max_vals):
|
||||
ax.plot(x_positions, avg_vals, marker="o", label="Avg Latency (ms)", color=color)
|
||||
ax.fill_between(x_positions, min_vals, max_vals, color=color, alpha=0.2, label="Min-Max Latency (ms)")
|
||||
for x, avg, minv, maxv in zip(x_positions, avg_vals, min_vals, max_vals):
|
||||
if avg is not None:
|
||||
ax.scatter(pr, avg, color=color)
|
||||
ax.text(pr, avg, f"{avg:.3f}", fontsize=14, ha="center", va="bottom")
|
||||
ax.scatter(x, avg, color=color)
|
||||
ax.text(x, avg, f"{avg:.3f}", fontsize=14, ha="center", va="bottom")
|
||||
if minv is not None and maxv is not None:
|
||||
ax.vlines(pr, minv, maxv, color=color, alpha=0.5)
|
||||
ax.vlines(x, minv, maxv, color=color, alpha=0.5)
|
||||
|
||||
ax.set_ylabel("Latency (ms)")
|
||||
ax.set_title(f"Scenario: {scenario}")
|
||||
@@ -73,7 +79,7 @@ def plot_latency_history(pr_numbers, scenario_data, output_path):
|
||||
|
||||
# Set X axis ticks and labels to show all PR numbers as 'PR <number>'
|
||||
axes[-1].set_xlabel("PR Number")
|
||||
axes[-1].set_xticks(pr_numbers)
|
||||
axes[-1].set_xticks(x_positions)
|
||||
axes[-1].set_xticklabels([f"PR {pr}" for pr in pr_numbers], rotation=45, ha="right", fontsize=14)
|
||||
|
||||
plt.tight_layout()
|
||||
@@ -86,7 +92,7 @@ if __name__ == "__main__":
|
||||
LATENCY_HISTORY_PATH = os.environ.get("LATENCY_HISTORY_PATH", "performance/output")
|
||||
LATENCY_HISTORY_PREFIX = os.environ.get("LATENCY_HISTORY_PREFIX", "pr")
|
||||
LATENCY_HISTORY_PLOT_FILENAME = os.environ.get("LATENCY_HISTORY_PLOT_FILENAME", "pr")
|
||||
glob_pattern = os.path.join(LATENCY_HISTORY_PATH, f"{LATENCY_HISTORY_PREFIX}*_latency.csv")
|
||||
glob_pattern = os.path.join(LATENCY_HISTORY_PATH, f"{LATENCY_HISTORY_PREFIX}[0-9]*_latency.csv")
|
||||
csv_files = sorted(glob.glob(glob_pattern))
|
||||
pr_numbers, scenario_data = parse_latency_csv(csv_files)
|
||||
output_path = os.path.join(LATENCY_HISTORY_PATH, LATENCY_HISTORY_PLOT_FILENAME)
|
||||
|
||||
Reference in New Issue
Block a user