Files
mev-beta/orig/scripts/performance-profile.sh
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01: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"