Files
mev-beta/scripts/performance-profile.sh
Krypto Kajun 850223a953 fix(multicall): resolve critical multicall parsing corruption issues
- Added comprehensive bounds checking to prevent buffer overruns in multicall parsing
- Implemented graduated validation system (Strict/Moderate/Permissive) to reduce false positives
- Added LRU caching system for address validation with 10-minute TTL
- Enhanced ABI decoder with missing Universal Router and Arbitrum-specific DEX signatures
- Fixed duplicate function declarations and import conflicts across multiple files
- Added error recovery mechanisms with multiple fallback strategies
- Updated tests to handle new validation behavior for suspicious addresses
- Fixed parser test expectations for improved validation system
- Applied gofmt formatting fixes to ensure code style compliance
- Fixed mutex copying issues in monitoring package by introducing MetricsSnapshot
- Resolved critical security vulnerabilities in heuristic address extraction
- Progress: Updated TODO audit from 10% to 35% complete

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 00:12:55 -05:00

46 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Performance profiling script
# Set default values
REPORT_DIR="${REPORT_DIR:-reports/performance}"
BINARY_DIR="${BINARY_DIR:-bin}"
BINARY_NAME="${BINARY_NAME:-mev-bot}"
PROFILE_TYPES="${PROFILE_TYPES:-cpu,mem,block,mutex}"
TIMEOUT="${TIMEOUT:-30s}"
echo "Starting performance profile..."
# Create report directory
mkdir -p "$REPORT_DIR"
# Build the application if it doesn't exist
if [ ! -f "$BINARY_DIR/$BINARY_NAME" ]; then
echo "Building application..."
make build
fi
# Run the application with profiling enabled
echo "Running application with profiling for $TIMEOUT..."
"$BINARY_DIR/$BINARY_NAME" --config config/development.yaml &
APP_PID=$!
# Wait for the app to start
sleep 2
# Profile the application
if command -v go &> /dev/null; then
# Use go tool pprof to profile the running application
echo "Profiling CPU for $TIMEOUT..."
go tool pprof -text -top -nodecount=10 "http://localhost:6060/debug/pprof/profile?seconds=${TIMEOUT%?}" > "$REPORT_DIR/cpu-profile.txt" 2>/dev/null || echo "Could not connect to pprof endpoint, make sure your app has debug/pprof enabled"
echo "Profiling memory..."
go tool pprof -text -top -nodecount=10 "http://localhost:6060/debug/pprof/heap" > "$REPORT_DIR/mem-profile.txt" 2>/dev/null || echo "Could not connect to heap profile endpoint"
fi
# Alternative: run a benchmark test if the application doesn't support pprof
echo "Running benchmark tests..."
go test -bench=. -benchmem -run=^$ ./pkg/... ./cmd/... > "$REPORT_DIR/benchmark-results.txt"
echo "Performance profiling complete. Reports saved to $REPORT_DIR"