summaryrefslogtreecommitdiff
path: root/scripts/pbo.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pbo.sh')
-rwxr-xr-xscripts/pbo.sh113
1 files changed, 0 insertions, 113 deletions
diff --git a/scripts/pbo.sh b/scripts/pbo.sh
deleted file mode 100755
index 909d28a..0000000
--- a/scripts/pbo.sh
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/bin/bash
-
-# Profile-Based Optimization (PBO) script for dgrep
-# This script automates the complete PBO process including baseline testing,
-# optimization application, and performance comparison
-
-set -e
-
-# Get the directory where this script is located
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-# Get the project root directory (parent of scripts)
-PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
-
-# Change to project root to run commands
-cd "$PROJECT_ROOT"
-
-# Define paths for all PBO files in scripts directory
-PBO_DIR="$SCRIPT_DIR"
-TEST_FILE="$PBO_DIR/test_100mb.txt"
-BASELINE_CPU_PROF="$PBO_DIR/pbo_baseline_cpu.prof"
-BASELINE_MEM_PROF="$PBO_DIR/pbo_baseline_mem.prof"
-OPTIMIZED_CPU_PROF="$PBO_DIR/pbo_optimized_cpu.prof"
-OPTIMIZED_MEM_PROF="$PBO_DIR/pbo_optimized_mem.prof"
-REPORT_FILE="$PBO_DIR/pbo_report.txt"
-
-echo "=== Starting Profile-Based Optimization (PBO) for dgrep ==="
-echo "Working directory: $PROJECT_ROOT"
-echo "PBO files location: $PBO_DIR"
-
-# 1. Create test file if needed
-echo "1. Creating test file if needed..."
-if [ ! -f "$TEST_FILE" ]; then
- echo "Creating 100MB test file with 1M lines..."
- for i in $(seq 1 1000000); do
- echo "$i: This is a test line with INFO level logging and some extra content to make it realistic"
- done > "$TEST_FILE"
-fi
-
-# 2. Run baseline performance test (assumes current state is baseline)
-echo "2. Running baseline performance test..."
-echo " - Generating CPU profile (baseline)..."
-./dgrep --plain -regex "INFO" -files "$TEST_FILE" -cpuprofile "$BASELINE_CPU_PROF" -memprofile "$BASELINE_MEM_PROF" > /dev/null
-
-echo " - Analyzing baseline profiles..."
-echo " CPU Profile (baseline):" > "$REPORT_FILE"
-go tool pprof -top "$BASELINE_CPU_PROF" | head -10 >> "$REPORT_FILE"
-echo " Memory Profile (baseline):" >> "$REPORT_FILE"
-go tool pprof -top "$BASELINE_MEM_PROF" | head -10 >> "$REPORT_FILE"
-
-# 3. Run performance benchmark
-echo "3. Running performance benchmark (3 iterations)..."
-echo " Baseline timings:" >> "$REPORT_FILE"
-for i in 1 2 3; do
- echo " Iteration $i:"
- (time ./dgrep --plain -regex "INFO" -files "$TEST_FILE" > /dev/null) 2>&1 | grep real >> "$REPORT_FILE"
-done
-
-# 4. Note optimizations (already implemented in code)
-echo "4. PBO optimizations are already implemented in the code"
-echo " - Timer allocation reduction (reusable timers)"
-echo " - I/O operation optimization (bulk writes, pre-allocated buffers)"
-echo " - Memory allocation improvements (buffer pooling)"
-
-# 5. Run optimized performance test
-echo "5. Running optimized performance test..."
-echo " - Generating CPU profile (optimized)..."
-./dgrep --plain -regex "INFO" -files "$TEST_FILE" -cpuprofile "$OPTIMIZED_CPU_PROF" -memprofile "$OPTIMIZED_MEM_PROF" > /dev/null
-
-echo " - Analyzing optimized profiles..."
-echo " CPU Profile (optimized):" >> "$REPORT_FILE"
-go tool pprof -top "$OPTIMIZED_CPU_PROF" | head -10 >> "$REPORT_FILE"
-echo " Memory Profile (optimized):" >> "$REPORT_FILE"
-go tool pprof -top "$OPTIMIZED_MEM_PROF" | head -10 >> "$REPORT_FILE"
-
-# 6. Run optimized benchmark
-echo "6. Running optimized benchmark (3 iterations)..."
-echo " Optimized timings:" >> "$REPORT_FILE"
-for i in 1 2 3; do
- echo " Iteration $i:"
- (time ./dgrep --plain -regex "INFO" -files "$TEST_FILE" > /dev/null) 2>&1 | grep real >> "$REPORT_FILE"
-done
-
-# 7. Generate comparison report
-echo "7. Generating comparison report..."
-echo "=== PROFILE-BASED OPTIMIZATION REPORT ===" >> "$REPORT_FILE"
-echo "Baseline memory usage:" >> "$REPORT_FILE"
-go tool pprof -top "$BASELINE_MEM_PROF" | grep "Showing nodes" >> "$REPORT_FILE" || echo "N/A" >> "$REPORT_FILE"
-echo "Optimized memory usage:" >> "$REPORT_FILE"
-go tool pprof -top "$OPTIMIZED_MEM_PROF" | grep "Showing nodes" >> "$REPORT_FILE" || echo "N/A" >> "$REPORT_FILE"
-echo "Baseline CPU samples:" >> "$REPORT_FILE"
-go tool pprof -top "$BASELINE_CPU_PROF" | grep "Total samples" >> "$REPORT_FILE" || echo "N/A" >> "$REPORT_FILE"
-echo "Optimized CPU samples:" >> "$REPORT_FILE"
-go tool pprof -top "$OPTIMIZED_CPU_PROF" | grep "Total samples" >> "$REPORT_FILE" || echo "N/A" >> "$REPORT_FILE"
-
-# 8. Summary
-echo "=== PBO Complete! ==="
-echo "Results saved to: $REPORT_FILE"
-echo "Profile files generated:"
-echo " - $BASELINE_CPU_PROF"
-echo " - $BASELINE_MEM_PROF"
-echo " - $OPTIMIZED_CPU_PROF"
-echo " - $OPTIMIZED_MEM_PROF"
-echo ""
-echo "Test file location: $TEST_FILE"
-echo ""
-echo "Key improvements implemented:"
-echo " ✓ Timer allocation reduction (eliminated time.After() calls)"
-echo " ✓ I/O operation optimization (bulk writes vs byte-by-byte)"
-echo " ✓ Memory allocation improvements (buffer pooling, pre-allocation)"
-echo ""
-
-# Show summary from report
-tail -20 "$REPORT_FILE" \ No newline at end of file