diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-26 21:10:07 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-26 21:10:07 +0300 |
| commit | 513c70e297059822384140ee7e5939d20fd0bdc1 (patch) | |
| tree | d6619230b54c4956d138c17c43df0fc72bb6f71a /profiling/profile_quick.sh | |
| parent | 4a657e44e7111d7d3b9a9ba5e453901e19af2ecb (diff) | |
refactor: move profiling scripts from benchmarks/ to profiling/
- Moved profile_benchmarks.sh, profile_dmap.sh, and profile_quick.sh
to the profiling/ directory where they belong
- Updated Makefile targets to reference new locations
- Fixed profile_dmap.sh to remove outfile clauses since they're not
needed for profiling and were preventing proper execution
- Updated .gitignore to exclude generated files in profiling/
This better separates benchmarking (performance comparison) from
profiling (performance analysis).
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'profiling/profile_quick.sh')
| -rwxr-xr-x | profiling/profile_quick.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/profiling/profile_quick.sh b/profiling/profile_quick.sh new file mode 100755 index 0000000..1aa9425 --- /dev/null +++ b/profiling/profile_quick.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# Quick profile script for dtail commands +# This runs profiling with smaller datasets for faster results + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +# Colors for output +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +# Default values +PROFILE_DIR="${PROFILE_DIR:-profiles}" +TEST_DATA_DIR="${TEST_DATA_DIR:-testdata}" + +# Create directories +mkdir -p "$PROFILE_DIR" +mkdir -p "$TEST_DATA_DIR" + +echo -e "${GREEN}DTail Quick Profiling${NC}" +echo "=====================" +echo + +# Generate test data if needed +if [ ! -f "$TEST_DATA_DIR/quick_test.log" ]; then + echo -e "${YELLOW}Generating test data...${NC}" + echo " Command: go run generate_profile_data.go -size \"10MB\" -output \"$TEST_DATA_DIR/quick_test.log\" -format log" + go run generate_profile_data.go -size "10MB" -output "$TEST_DATA_DIR/quick_test.log" -format log + echo " Command: go run generate_profile_data.go -size \"10MB\" -output \"$TEST_DATA_DIR/quick_test.csv\" -format csv" + go run generate_profile_data.go -size "10MB" -output "$TEST_DATA_DIR/quick_test.csv" -format csv +fi + +# Build commands +echo -e "${GREEN}Building commands...${NC}" +echo " Command: cd .. && make dcat dgrep dmap" +cd .. +make dcat dgrep dmap 2>/dev/null || true +cd "$SCRIPT_DIR" + +echo +echo -e "${GREEN}Running quick profiles...${NC}" + +# Profile dcat +echo -e "\n${YELLOW}Profiling dcat...${NC}" +echo "Command: ../dcat -profile -profiledir $PROFILE_DIR -plain -cfg none $TEST_DATA_DIR/quick_test.log" +../dcat -profile -profiledir "$PROFILE_DIR" -plain -cfg none "$TEST_DATA_DIR/quick_test.log" > /dev/null 2>&1 +DCAT_CPU=$(ls -t "$PROFILE_DIR"/dcat_cpu_*.prof 2>/dev/null | head -1) +if [ -n "$DCAT_CPU" ]; then + echo " Generated: $(basename "$DCAT_CPU")" + echo " Analysis: ../profiling/profile.sh -top 3 $DCAT_CPU" + ../profiling/profile.sh -top 3 "$DCAT_CPU" | grep -A 5 "Top 3 functions" +fi + +# Profile dgrep +echo -e "\n${YELLOW}Profiling dgrep...${NC}" +echo "Command: ../dgrep -profile -profiledir $PROFILE_DIR -plain -cfg none -regex \"user[0-9]+\" $TEST_DATA_DIR/quick_test.log" +../dgrep -profile -profiledir "$PROFILE_DIR" -plain -cfg none -regex "user[0-9]+" "$TEST_DATA_DIR/quick_test.log" > /dev/null 2>&1 +DGREP_CPU=$(ls -t "$PROFILE_DIR"/dgrep_cpu_*.prof 2>/dev/null | head -1) +if [ -n "$DGREP_CPU" ]; then + echo " Generated: $(basename "$DGREP_CPU")" + echo " Analysis: ../profiling/profile.sh -top 3 $DGREP_CPU" + ../profiling/profile.sh -top 3 "$DGREP_CPU" | grep -A 5 "Top 3 functions" +fi + +# Profile dmap +echo -e "\n${YELLOW}Profiling dmap...${NC}" +echo "Command: ../dmap -profile -profiledir $PROFILE_DIR -plain -cfg none -query \"select count(*) from $TEST_DATA_DIR/quick_test.csv\"" +../dmap -profile -profiledir "$PROFILE_DIR" -plain -cfg none -query "select count(*) from $TEST_DATA_DIR/quick_test.csv" > /dev/null 2>&1 +DMAP_CPU=$(ls -t "$PROFILE_DIR"/dmap_cpu_*.prof 2>/dev/null | head -1) +if [ -n "$DMAP_CPU" ]; then + echo " Generated: $(basename "$DMAP_CPU")" + echo " Analysis: ../profiling/profile.sh -top 3 $DMAP_CPU" + ../profiling/profile.sh -top 3 "$DMAP_CPU" | grep -A 5 "Top 3 functions" +fi + +echo +echo -e "${GREEN}Quick profiling complete!${NC}" +echo +echo "To analyze in detail:" +echo " go tool pprof $PROFILE_DIR/<profile_file>" +echo " make profile-flamegraph PROFILE=$PROFILE_DIR/<profile_file>" +echo
\ No newline at end of file |
