#!/bin/bash

NTHREADS=$1
shift
echo "Running $NTHREADS"

mkdir -p out
rm out/*
echo "httperf --client [0-$(($NTHREADS - 1))]/$NTHREADS $@ > out/result.[0-$(($NTHREADS - 1))].out"
for ((i=0; i<$NTHREADS; i++))
do
	httperf --client $i/$NTHREADS $@ > out/result.$i.out &
done

wait
echo "Experiment terminated"

FILES=""
for ((i=0; i<$NTHREADS; i++))
do
	FILES="$FILES out/result.$i.out"
done
./parse-httperf.py $FILES ||  echo $FILES