Skip to content

Pts #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Pts #42

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 287 additions & 16 deletions phoronix/reduce_phoronix
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,288 @@
#!/bin/bash
egrep 'Test: |Average' results_phoronix_tuned_*.out | grep -v stress > tmpfile
echo "Test:BOPs"
toggle=0
while IFS= read -r line
do
if [ $toggle -eq 0 ]; then
out=`echo $line | cut -d':' -f2 | sed "s/^ //g" | sed "s/\[1\;34m//g"`
printf "%s:" "$out"
toggle=1
else
out=`echo $line | cut -d':' -f 2 | cut -d' ' -f 2 | sed "s/\[1\;34m//g"`
printf "%s\n" $out
toggle=0
fi
done < "tmpfile"
rm tmpfile

usage() {
echo "Usage:"
echo " ./reduce_phoronix --sub_test <test_ran> --tmp_name <output_temp_file>"
echo "Options:"
echo " -h Show help"
echo " --sub_test Specify the test data to reduce"
echo " --tmp_file Specify output temp file"
exit 1
}

# Initialize variables
test_ran="none"
tmp_file="none"

reduce_cockroach() {
echo "Workload:Concurrency:Average:Deviation" > "$tmp_file"
# Read and process the results file
while IFS= read -r line; do
# Check for lines containing workload and concurrency
if [[ $line == *Workload* ]]; then
# Extract Workload and Concurrency
workload=$(echo "$line" | awk -F ': ' '{print $2}' | awk -F ' - ' '{print $1}')
concurrency=$(echo "$line" | awk -F ': ' '{print $3}' | tr -d ':')
fi
if [[ $line == *Average* ]]; then
# Extract Average
average=$(echo "$line" | awk -F ': ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *Deviation* ]]; then
# Extract Deviation
deviation=$(echo "$line" | awk -F ': ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$workload:$concurrency:$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_phpbench() {
echo "Average:Deviation" > "$tmp_file"
# Read and process the results file
while IFS= read -r line; do
if [[ $line == *"Average:"* ]]; then
# Extract Average value
average=$(echo "$line" | awk -F 'Average: ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *"Deviation:"* ]]; then
# Extract Deviation value
deviation=$(echo "$line" | awk -F 'Deviation: ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_redis() {
echo "Test:ParallelConnections:Average:Deviation" > "$tmp_file"
# Read and process the results file
while IFS= read -r line; do
# Check for lines containing Test and Parallel Connections
if [[ $line == *"Test:"* && $line == *"Parallel Connections:"* ]]; then
# Extract Test and Parallel Connections
test=$(echo "$line" | awk -F 'Test: ' '{print $2}' | awk -F ' - ' '{print $1}')
parallel_connections=$(echo "$line" | awk -F ': ' '{print $3}' | tr -d ':')
fi
if [[ $line == *"Average:"* ]]; then
# Extract Average
average=$(echo "$line" | awk -F ': ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *"Deviation:"* ]]; then
# Extract Deviation
deviation=$(echo "$line" | awk -F ': ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$test:$parallel_connections:$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_cassandra() {
echo "Test:Average:Deviation" > "$tmp_file"
# Read and process the results file
while IFS= read -r line; do
# Check for lines containing Test
if [[ $line == *"Test:"* ]]; then
# Extract Test name (after "Test: " and before the colon)
test=$(echo "$line" | awk -F 'Test: ' '{print $2}' | awk -F ':' '{print $1}')
fi
if [[ $line == *"Average:"* ]]; then
# Extract Average value
average=$(echo "$line" | awk -F 'Average: ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *"Deviation:"* ]]; then
# Extract Deviation value
deviation=$(echo "$line" | awk -F 'Deviation: ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$test:$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_apache-iotdb() {
# Header for CSV file
echo "device_count:batch_size:sensor_count:client_number:point_sec:latency" > "$tmp_file"

# Initialize variables to store values for each test configuration
device_count=""
batch_size=""
sensor_count=""
client_number=""
point_sec=""
latency=""
# Iterate through the test output file (replace this with the actual test output file)
while IFS= read -r line; do
# Extract the configuration line (e.g., Device Count: 100 - Batch Size Per Write: 1 - Sensor Count: 200 - Client Number: 100)
if [[ "$line" =~ \[\Device\ Count:\ ([0-9]+).*Batch\ Size\ Per\ Write:\ ([0-9]+).*Sensor\ Count:\ ([0-9]+).*Client\ Number:\ ([0-9]+)] ]]; then
# Save the configuration
device_count="${BASH_REMATCH[1]}"
batch_size="${BASH_REMATCH[2]}"
sensor_count="${BASH_REMATCH[3]}"
client_number="${BASH_REMATCH[4]}"
fi
# Extract points/sec (e.g., Average: 139645 point/sec)
if [[ "$line" =~ Average:\ ([0-9]+)\ point/sec ]]; then
point_sec="${BASH_REMATCH[1]}"
fi
# Extract latency (e.g., Average Latency: 117.59)
if [[ "$line" =~ Average\ Latency:\ ([0-9]+\.[0-9]+) ]]; then
latency="${BASH_REMATCH[1]}"
fi
# After reading the point_sec and latency for a test configuration, append it to the output CSV
if [[ -n "$device_count" && -n "$batch_size" && -n "$sensor_count" && -n "$client_number" ]]; then
echo "$device_count:$batch_size:$sensor_count:$client_number:${point_sec:-}:$latency" >> "$tmp_file"
device_count=""
batch_size=""
sensor_count=""
client_number=""
point_sec=""
latency=""
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_nginx(){
echo "Connections:RPS" > "$tmp_file"
while IFS= read -r line; do
# Check for lines containing Connections
if [[ $line == *"Connections:"* ]]; then
# Extract Test name (after "Connections: " and before the colon)
connection=$(echo "$line" | awk -F 'Connections: ' '{print $2}' | awk -F ':' '{print $1}')
fi
if [[ $line == *"Average:"* ]]; then
# Extract Average value
average=$(echo "$line" | awk -F 'Average: ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *"Deviation:"* ]]; then
# Extract Deviation value
deviation=$(echo "$line" | awk -F 'Deviation: ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$connection:$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_stress_ng() {
echo "Test:Average:Deviation" > "$tmp_file"
# Read and process the results file
while IFS= read -r line; do
# Check for lines containing Test
if [[ $line == *"Test:"* ]]; then
# Extract Test name (after "Test: " and before the colon)
test=$(echo "$line" | awk -F 'Test: ' '{print $2}' | awk -F ':' '{print $1}')
fi
if [[ $line == *"Average:"* ]]; then
# Extract Average value
average=$(echo "$line" | awk -F 'Average: ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *"Deviation:"* ]]; then
# Extract Deviation value
deviation=$(echo "$line" | awk -F 'Deviation: ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$test:$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_sqlite() {
echo "Threads:Average:Deviation" > "$tmp_file"
# Read and process the results file
while IFS= read -r line; do
# Check for lines containing Threads
if [[ $line == *"Threads / Copies:"* ]]; then
# Extract Test name (after "Test: " and before the colon)
test=$(echo "$line" | awk -F 'Threads / Copies: ' '{print $2}' | awk -F ':' '{print $1}')
fi
if [[ $line == *"Average:"* ]]; then
# Extract Average value
average=$(echo "$line" | awk -F 'Average: ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *"Deviation:"* ]]; then
# Extract Deviation value
deviation=$(echo "$line" | awk -F 'Deviation: ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$threads:$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

reduce_openssl() {
echo "Algorithm:BPS:Deviation" > "$tmp_file"
# Read and process the results file
while IFS= read -r line; do
# Check for lines containing Threads
if [[ $line == *"Algorithm:"* ]]; then
# Extract Algorithm name (after "Algorithm: " and before the colon)
algorithm=$(echo "$line" | awk -F 'Algorithm: ' '{print $2}' | awk -F ':' '{print $1}')
fi
if [[ $line == *"Average:"* ]]; then
# Extract Average value
average=$(echo "$line" | awk -F 'Average: ' '{print $2}' | awk '{print $1}')
fi
if [[ $line == *"Deviation:"* ]]; then
# Extract Deviation value
deviation=$(echo "$line" | awk -F 'Deviation: ' '{print $2}' | tr -d '%')
# Append the extracted information to the output file
echo "$algorithm:$average:$deviation" >> "$tmp_file"
fi
done < /tmp/results_phoronix_"$test_ran"_tuned_*.out
}

# Check if an argument is passed
if [ $# -eq 0 ]; then
usage
fi


# Process command line arguments
while [ $# -gt 0 ]; do
case $1 in
-h)
usage
;;
--sub_test)
test_ran=$2
shift 2
;;
--tmp_file)
tmp_file=$2
shift 2
;;
*)
usage
;;
esac
done

# Check if a test data to reduce is designated
if [ "$test_ran" == "none" ]; then
echo "You need to designate a test to reduce."
usage
fi
if [ "$tmp_file" == "none" ]; then
echo "You need a file to output to"
usage
fi

if [[ ${test_ran} == "cockroach" ]]; then
reduce_cockroach
elif [[ ${test_ran} == "redis" ]]; then
reduce_redis
elif [[ ${test_ran} == "stress-ng" ]]; then
reduce_stress_ng
elif [[ ${test_ran} == "phpbench" ]]; then
reduce_phpbench
elif [[ ${test_ran} == "cassandra" ]]; then
reduce_cassandra
elif [[ ${test_ran} == "apache-iotdb" ]]; then
reduce_apache-iotdb
elif [[ ${test_ran} == "nginx" ]]; then
reduce_nginx
elif [[ ${test_ran} == "sqlite" ]]; then
reduce_sqlite
elif [[ ${test_ran} == "openssl" ]]; then
reduce_openssl
else
echo "Unsupported test: ${test_ran}"
exit 1
fi
Loading