|
| 1 | +#!/bin/bash |
| 2 | +# Script to embed graphs in the comparison HTML |
| 3 | + |
| 4 | +COMPARISON_HTML="$1" |
| 5 | +COMPARE_DIR="$2" |
| 6 | + |
| 7 | +# Check if comparison.html exists |
| 8 | +if [ ! -f "$COMPARISON_HTML" ]; then |
| 9 | + echo "ERROR: $COMPARISON_HTML not found" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +# Create a backup of the original |
| 14 | +cp "$COMPARISON_HTML" "${COMPARISON_HTML}.bak" |
| 15 | + |
| 16 | +# Create new HTML with embedded graphs |
| 17 | +{ |
| 18 | + echo '<!DOCTYPE html>' |
| 19 | + echo '<html><head>' |
| 20 | + echo '<title>mmtests Comparison with Graphs</title>' |
| 21 | + echo '<style>' |
| 22 | + echo 'body { font-family: Arial, sans-serif; margin: 20px; background-color: #f5f5f5; }' |
| 23 | + echo '.container { max-width: 1400px; margin: 0 auto; background: white; padding: 30px; border-radius: 10px; box-shadow: 0 0 20px rgba(0,0,0,0.1); }' |
| 24 | + echo '.resultsTable { border-collapse: collapse; width: 100%; margin: 20px 0; }' |
| 25 | + echo '.resultsTable th { background-color: #3498db; color: white; padding: 10px; text-align: center; font-weight: bold; }' |
| 26 | + echo '.resultsTable td { padding: 8px; text-align: right; font-family: monospace; border-bottom: 1px solid #ddd; }' |
| 27 | + echo '.resultsTable tr:nth-child(odd) { background: #f9f9f9; }' |
| 28 | + echo '.graph-section { background: #ecf0f1; padding: 20px; border-radius: 10px; margin: 20px 0; }' |
| 29 | + echo '.graph-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); gap: 20px; }' |
| 30 | + echo '.graph-item { text-align: center; }' |
| 31 | + echo '.graph-item img { max-width: 100%; height: auto; border: 1px solid #ddd; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }' |
| 32 | + echo 'h1 { color: #2c3e50; text-align: center; border-bottom: 3px solid #3498db; padding-bottom: 10px; }' |
| 33 | + echo 'h2 { color: #34495e; border-left: 4px solid #3498db; padding-left: 15px; }' |
| 34 | + echo 'h3 { color: #34495e; font-size: 1.1em; }' |
| 35 | + echo '</style>' |
| 36 | + echo '</head><body>' |
| 37 | + echo '<div class="container">' |
| 38 | + echo '<h1>mmtests Performance Comparison</h1>' |
| 39 | + |
| 40 | + # Add graphs section if any graphs exist |
| 41 | + if ls "$COMPARE_DIR"/*.png >/dev/null 2>&1; then |
| 42 | + echo '<div class="graph-section">' |
| 43 | + echo '<h2>Performance Graphs</h2>' |
| 44 | + echo '<div class="graph-grid">' |
| 45 | + |
| 46 | + # Main benchmark graph first |
| 47 | + for graph in "$COMPARE_DIR"/graph-*compact.png; do |
| 48 | + if [ -f "$graph" ] && [[ ! "$graph" =~ -sorted|-smooth ]]; then |
| 49 | + echo '<div class="graph-item">' |
| 50 | + echo '<h3>Main Performance Comparison</h3>' |
| 51 | + echo "<img src='$(basename "$graph")' alt='Main Performance'>" |
| 52 | + echo '</div>' |
| 53 | + fi |
| 54 | + done |
| 55 | + |
| 56 | + # Sorted graph |
| 57 | + if [ -f "$COMPARE_DIR/graph-thpcompact-sorted.png" ]; then |
| 58 | + echo '<div class="graph-item">' |
| 59 | + echo '<h3>Sorted Samples</h3>' |
| 60 | + echo '<img src="graph-thpcompact-sorted.png" alt="Sorted Samples">' |
| 61 | + echo '</div>' |
| 62 | + fi |
| 63 | + |
| 64 | + # Smooth graph |
| 65 | + if [ -f "$COMPARE_DIR/graph-thpcompact-smooth.png" ]; then |
| 66 | + echo '<div class="graph-item">' |
| 67 | + echo '<h3>Smoothed Trend</h3>' |
| 68 | + echo '<img src="graph-thpcompact-smooth.png" alt="Smoothed Trend">' |
| 69 | + echo '</div>' |
| 70 | + fi |
| 71 | + |
| 72 | + # Any monitor graphs |
| 73 | + for graph in "$COMPARE_DIR"/graph-vmstat.png "$COMPARE_DIR"/graph-proc-vmstat.png "$COMPARE_DIR"/graph-mpstat.png; do |
| 74 | + if [ -f "$graph" ]; then |
| 75 | + graphname=$(basename "$graph" .png | sed 's/graph-//') |
| 76 | + echo '<div class="graph-item">' |
| 77 | + echo "<h3>${graphname^^} Monitor</h3>" |
| 78 | + echo "<img src='$(basename "$graph")' alt='$graphname'>" |
| 79 | + echo '</div>' |
| 80 | + fi |
| 81 | + done |
| 82 | + |
| 83 | + echo '</div>' |
| 84 | + echo '</div>' |
| 85 | + fi |
| 86 | + |
| 87 | + # Add the original comparison table |
| 88 | + echo '<div class="graph-section">' |
| 89 | + echo '<h2>Detailed Comparison Table</h2>' |
| 90 | + cat "$COMPARISON_HTML" |
| 91 | + echo '</div>' |
| 92 | + |
| 93 | + echo '</div></body></html>' |
| 94 | +} > "${COMPARISON_HTML}.new" |
| 95 | + |
| 96 | +# Replace the original with the new version |
| 97 | +mv "${COMPARISON_HTML}.new" "$COMPARISON_HTML" |
| 98 | + |
| 99 | +echo "Graphs embedded in $COMPARISON_HTML" |
| 100 | +exit 0 |
0 commit comments