Skip to content

Commit bde429d

Browse files
coderbirjuKern--
authored andcommitted
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 <[email protected]>
1 parent 8d2f1c5 commit bde429d

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
set -eux -o pipefail
4+
5+
if [ $# -ne 2 ]; then
6+
echo "Usage: $0 <path_to_results.json> <path_to_output_dir.json>"
7+
exit 1
8+
fi
9+
10+
# Read the input JSON file
11+
input_file="$1"
12+
output_dir="$2"
13+
14+
# Check if the input file exists
15+
if [ ! -f "$input_file" ]; then
16+
echo "Error: Input file '$input_file' not found."
17+
exit 1
18+
fi
19+
20+
# Function to create JSON file for each testName
21+
create_json_file() {
22+
local test_name="$1"
23+
local lazy_task_value="$2"
24+
local local_task_value="$3"
25+
local pull_task_value="$4"
26+
27+
# mkdir -p ../pre-processed-results
28+
# Define the output JSON file name
29+
local output_file="${output_dir}/${test_name}.json"
30+
31+
# Create the JSON content
32+
local json_content='[{
33+
"name": "'"$test_name"'-lazyTaskDuration",
34+
"unit": "Seconds",
35+
"value": '"$lazy_task_value"',
36+
"extra": "P90"
37+
},
38+
{
39+
"name": "'"$test_name"'-localTaskDuration",
40+
"unit": "Seconds",
41+
"value": '"$local_task_value"',
42+
"extra": "P90"
43+
},
44+
{
45+
"name": "'"$test_name"'-pullTaskDuration",
46+
"unit": "Seconds",
47+
"value": '"$pull_task_value"',
48+
"extra": "P90"
49+
}]'
50+
51+
# Save the JSON content to the output file
52+
echo "$json_content" > "$output_file"
53+
}
54+
55+
# Parse the JSON using jq
56+
commit=$(jq -r '.commit' "$input_file")
57+
tests=$(jq -r '.benchmarkTests | length' "$input_file")
58+
59+
# Loop through each test and extract the required data
60+
for ((i = 0; i < tests; i++)); do
61+
testName=$(jq -r --argjson i $i '.benchmarkTests[$i].testName' "$input_file")
62+
63+
# Lazy Task Stats
64+
lazyTaskPct90=$(jq -r --argjson i $i '.benchmarkTests[$i].lazyTaskStats.pct90' "$input_file")
65+
66+
# Local Task Stats
67+
localTaskPct90=$(jq -r --argjson i $i '.benchmarkTests[$i].localTaskStats.pct90' "$input_file")
68+
69+
pullTaskPct90=$(jq -r --argjson i $i '.benchmarkTests[$i].pullStats.pct90' "$input_file")
70+
71+
# Create JSON file for each testName
72+
create_json_file "$testName" "$lazyTaskPct90" "$localTaskPct90" "$pullTaskPct90"
73+
done

0 commit comments

Comments
 (0)