new_runner.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. kill_process_tree() {
  3. local pid=$1
  4. # Get all child processes using pgrep
  5. local children=$(pgrep -P $pid)
  6. # Kill children first
  7. for child in $children; do
  8. kill_process_tree $child
  9. done
  10. # Kill the parent process
  11. kill -9 $pid 2>/dev/null || true
  12. }
  13. # Function to run the runner and benchmark for a given model
  14. run_benchmark() {
  15. local model=$1
  16. echo "Starting runner with model: $model"
  17. # Start the runner in background and save its PID
  18. go run ../cmd/runner/main.go --new-runner -model "$model" &
  19. runner_pid=$!
  20. # Wait for the runner to initialize (adjust sleep time as needed)
  21. sleep 5
  22. echo "Running benchmark..."
  23. # Run test and wait for it to complete
  24. go test -bench=Runner
  25. test_exit_code=$?
  26. echo "Stopping runner process..."
  27. # Kill the runner process and all its children
  28. kill_process_tree $runner_pid
  29. # Wait for the process to fully terminate
  30. wait $runner_pid 2>/dev/null || true
  31. # Make sure no processes are still listening on port 8080
  32. lsof -t -i:8080 | xargs kill -9 2>/dev/null || true
  33. # Additional sleep to ensure port is freed
  34. sleep 2
  35. # Check if test failed
  36. if [ $test_exit_code -ne 0 ]; then
  37. echo "Warning: Benchmark test failed with exit code $test_exit_code"
  38. fi
  39. echo "Benchmark complete for model: $model"
  40. echo "----------------------------------------"
  41. }
  42. HOME_DIR="$HOME"
  43. # llama3.2:1b: ~/.ollama/models/blobs/sha256-74701a8c35f6c8d9a4b91f3f3497643001d63e0c7a84e085bed452548fa88d45
  44. # llama3.1:8b: ~/.ollama/models/blobs/sha256-667b0c1932bc6ffc593ed1d03f895bf2dc8dc6df21db3042284a6f4416b06a29
  45. # llama3.3:70b: ~/.ollama/models/blobs/sha256-4824460d29f2058aaf6e1118a63a7a197a09bed509f0e7d4e2efb1ee273b447d
  46. models=(
  47. "${HOME_DIR}/.ollama/models/blobs/sha256-74701a8c35f6c8d9a4b91f3f3497643001d63e0c7a84e085bed452548fa88d45"
  48. "${HOME_DIR}/.ollama/models/blobs/sha256-667b0c1932bc6ffc593ed1d03f895bf2dc8dc6df21db3042284a6f4416b06a29"
  49. # "${HOME_DIR}/.ollama/models/blobs/sha256-4824460d29f2058aaf6e1118a63a7a197a09bed509f0e7d4e2efb1ee273b447d"
  50. )
  51. # Run benchmarks for each model
  52. for model in "${models[@]}"; do
  53. run_benchmark "$model"
  54. done
  55. echo "All benchmarks completed!"