<commit_before>
#!/bin/sh

# Demostrate API calls for REST HTTP IPC and RPC IPC via API Gateway
# Requires HTTPie
# Requires all services are running

set -e

HOST=$1 || localhost
TEST_CYCLES=$2 || 25
API_GATEWAY="http://${HOST}:8080"
ELECTION="2016%20Presidential%20Election"

http ${API_GATEWAY}/candidate/simulation --pretty=none
http ${API_GATEWAY}/candidate/candidates/summary/election/${ELECTION} --pretty=none

echo "Using REST HTTP IPC..."
TIME1=$(date +%s)
for i in $(seq ${TEST_CYCLES})
do
  http ${API_GATEWAY}/voter/candidates/election/${ELECTION} --pretty=none
done
TIME2=$(date +%s)

TIME3=`expr ${TIME2} - ${TIME1}`

echo "Using Message-based RPC IPC..."
TIME4=$(date +%s)
for i in $(seq ${TEST_CYCLES})
do
  http ${API_GATEWAY}/voter/candidates/rpc/election/${ELECTION} --pretty=none
done
TIME5=$(date +%s)

TIME6=`expr ${TIME5} - ${TIME4}`

echo ""
echo "REST HTTP: ${TIME3} seconds for ${TEST_CYCLES} test cycles"
echo "  RPC IPC: ${TIME6} seconds for ${TEST_CYCLES} test cycles"

echo ""
echo "Script completed..."<commit_msg>Refactor demo scripts<commit_after>
#!/bin/sh

# Demostrate API calls for REST HTTP IPC and RPC IPC via API Gateway
# Requires HTTPie
# Requires all services are running

set -e

HOST=$1 || localhost
TEST_CYCLES=$2 || 25
API_GATEWAY="http://${HOST}:8080"
ELECTION="2016%20Presidential%20Election"
PARAMS="--pretty=none --headers > /dev/null"

echo "Simulating candidates..."
http ${API_GATEWAY}/candidate/simulation ${PARAMS}
http ${API_GATEWAY}/candidate/candidates/summary/election/${ELECTION} ${PARAMS}

echo "Using REST HTTP IPC..."
TIME1=$(date +%s)
for i in $(seq ${TEST_CYCLES})
do
  http ${API_GATEWAY}/voter/candidates/election/${ELECTION} ${PARAMS}
done
TIME2=$(date +%s)

TIME3=`expr ${TIME2} - ${TIME1}`

echo "Using Message-based RPC IPC..."
TIME4=$(date +%s)
for i in $(seq ${TEST_CYCLES})
do
  http ${API_GATEWAY}/voter/candidates/rpc/election/${ELECTION} ${PARAMS}
done
TIME5=$(date +%s)

TIME6=`expr ${TIME5} - ${TIME4}`

echo ""
echo "REST HTTP: ${TIME3} seconds for ${TEST_CYCLES} test cycles"
echo "  RPC IPC: ${TIME6} seconds for ${TEST_CYCLES} test cycles"

echo ""
echo "Script completed..."
{'fraction_non_alphanumeric': 0.1713756368689208, 'fraction_numerical': 0.025937934228809634, 'mean_word_length': 5.22478386167147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1536588', 'n_tokens_mistral': 842, 'n_tokens_neox': 804, 'n_words': 213}