Skip to content

Integration Performance

Aron Heesakkers edited this page Jun 4, 2021 · 9 revisions

Integration Performance

Works in:

  • Linux Bash terminal
  • Mac ZSH terminal
  • Git Bash Windows
  • Windows PowerShell
  • Windows CMD

Test the response time of GET requests.

Use this function by copy pasting this function in your shell.

Arguments:

  • Argument $1: Endpoint : String
  • Argument $2: Iterations : Number
function LogPerformance () {
#bin/bash

  total_timestamp_start=$(date +"%s")

  echo "----------------------------"
  echo ""
  echo ""
  echo Starting iterations...
  echo ""
  echo ""

  for i in {0..$2}
  do
    req_timestamp_start=$(date +"%s")
    curl -s $1> /dev/null
    req_timestamp_end=$(date +"%s")
    echo Iteration $i: $(($req_timestamp_end - $req_timestamp_start)) seconds
    echo ""
  done
  total_timestamp_end=$(date +"%s")

  echo "----------------------------"
  echo ""

  diff=$(($total_timestamp_end - $total_timestamp_start))
  echo Time requesting $i Packages: $(($diff / 60)) Minutes and $((diff % 60)) seconds                         

  echo ""
}

Example usage

LogPerformance https://gateway.fipost.nl/api/packages 3

Example response

----------------------------


Starting iterations...


Iteration 0: 5 seconds

Iteration 1: 12 seconds

Iteration 2: 20 seconds

Iteration 3: 14 seconds

----------------------------

Time requesting 3 Packages: 0 Minutes and 51 seconds

Clone this wiki locally