From bde429dbb4bc08c3b80920909df240b812a87c62 Mon Sep 17 00:00:00 2001 From: Arjun Yogidas Date: Fri, 28 Jul 2023 16:45:45 +0000 Subject: [PATCH] Add shell script for benchmark visualization This commit adds a visualization_data_converter shell script that accepts a results json file and converts it to a benchmark result compatible format for the visualization tool. The script generates the data in the correct format for each diffrent image. Signed-off-by: Arjun Raja Yogidas --- scripts/visualization_data_converter.sh | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 scripts/visualization_data_converter.sh diff --git a/scripts/visualization_data_converter.sh b/scripts/visualization_data_converter.sh new file mode 100755 index 000000000..033b26097 --- /dev/null +++ b/scripts/visualization_data_converter.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -eux -o pipefail + +if [ $# -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Read the input JSON file +input_file="$1" +output_dir="$2" + +# Check if the input file exists +if [ ! -f "$input_file" ]; then + echo "Error: Input file '$input_file' not found." + exit 1 +fi + +# Function to create JSON file for each testName +create_json_file() { + local test_name="$1" + local lazy_task_value="$2" + local local_task_value="$3" + local pull_task_value="$4" + +# mkdir -p ../pre-processed-results + # Define the output JSON file name + local output_file="${output_dir}/${test_name}.json" + + # Create the JSON content + local json_content='[{ + "name": "'"$test_name"'-lazyTaskDuration", + "unit": "Seconds", + "value": '"$lazy_task_value"', + "extra": "P90" + }, + { + "name": "'"$test_name"'-localTaskDuration", + "unit": "Seconds", + "value": '"$local_task_value"', + "extra": "P90" + }, + { + "name": "'"$test_name"'-pullTaskDuration", + "unit": "Seconds", + "value": '"$pull_task_value"', + "extra": "P90" + }]' + + # Save the JSON content to the output file + echo "$json_content" > "$output_file" +} + +# Parse the JSON using jq +commit=$(jq -r '.commit' "$input_file") +tests=$(jq -r '.benchmarkTests | length' "$input_file") + +# Loop through each test and extract the required data +for ((i = 0; i < tests; i++)); do + testName=$(jq -r --argjson i $i '.benchmarkTests[$i].testName' "$input_file") + + # Lazy Task Stats + lazyTaskPct90=$(jq -r --argjson i $i '.benchmarkTests[$i].lazyTaskStats.pct90' "$input_file") + + # Local Task Stats + localTaskPct90=$(jq -r --argjson i $i '.benchmarkTests[$i].localTaskStats.pct90' "$input_file") + + pullTaskPct90=$(jq -r --argjson i $i '.benchmarkTests[$i].pullStats.pct90' "$input_file") + + # Create JSON file for each testName + create_json_file "$testName" "$lazyTaskPct90" "$localTaskPct90" "$pullTaskPct90" +done \ No newline at end of file