Skip to content

Instantly share code, notes, and snippets.

@sdesalas
Last active March 22, 2024 12:16
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 sdesalas/0fb0d24a91f5d92f71a992452de1162b to your computer and use it in GitHub Desktop.
Save sdesalas/0fb0d24a91f5d92f71a992452de1162b to your computer and use it in GitHub Desktop.
Poor mans apache bench
#! /bin/bash
#
# CurlBench. Dont want to install apache bench?
#
# Runs "curl" concurrently using arguments.
#
# Example: Make 100 requests to some domain (concurrency = 10)
# $ curl.sh http://some.domain.com 100 10
#
set -B
url=${1:-http://some.domain.com}
count=${2:-1}
concurrency=${3:-1}
iterations=$((count/concurrency))
for i in $(seq 1 $iterations); do
echo '';
echo "$i ------------------------";
echo "GET $url"
echo '';
seq 1 $concurrency | xargs -I $ -n1 -P$concurrency curl -D - "$url";
echo '';
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment