Skip to content

Instantly share code, notes, and snippets.

@slutske22
Last active December 26, 2021 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slutske22/bbd80940e2c8cd2acd111a69595b7a57 to your computer and use it in GitHub Desktop.
Save slutske22/bbd80940e2c8cd2acd111a69595b7a57 to your computer and use it in GitHub Desktop.
profiler.sh
# Set environment variables
export PORT=4000
export PROFILER=true
export OUTPUT_DIR="profiles/$(date +%s)"
# Leverage pm2 to start server on specific port:
pm2 start npm --name server-profiler -- start
# Wait for server to start and then ping with post request to run campaign
npx wait-on http://localhost:4000
# Use apache benchmark to post request to complex route
ab -n 1 http://localhost:4000/api/complex > "./${OUTPUT_DIR}/ABResults.txt" 2>&1
# Cleanup running process
pm2 stop server-profiler
pm2 delete server-profiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment