Skip to content

Commit ae24e70

Browse files
committed
Add support to upload JSON results (Issue #9)
1 parent e59709c commit ae24e70

File tree

3 files changed

+114
-14
lines changed

3 files changed

+114
-14
lines changed

Diff for: README.md

+11
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,22 @@ curl -sL yabs.sh | bash -s -- -{bfdighr49}
4141
* `-r` this option reduces the number of iperf locations (Online.net/Clouvider LON+NYC) to lessen bandwidth usage
4242
* `-4` this option overrides the Geekbench 5 performance test and runs a Geekbench 4 test instead
4343
* `-9` this option runs the Geekbench 4 test in addition to the Geekbench 5 test
44+
* `-j <url>` this option sends a JSON representation of the results to the designated URL (see section below)
4445

4546
Options can be grouped together to skip multiple tests, i.e. `-fg` to skip the disk and system performance tests (effectively only testing network performance).
4647

4748
**Geekbench License Key**: A Geekbench license key can be utilized during the Geekbench test to unlock all features. Simply put the email and key for the license in a file called _geekbench.license_. `echo "[email protected] ABCDE-12345-FGHIJ-57890" > geekbench.license`
4849

50+
### Submitting JSON Results
51+
52+
Results from running this script can be sent to your benchmark results website of choice in JSON format. Invoke the `-j` flag and pass the URL to where the results should be submitted to:
53+
54+
```
55+
curl -sL yabs.sh | bash -s -- -j "https://example.com/yabs/post"
56+
```
57+
58+
A list of websites supporting acceptance of YABS JSON results will be posted here (when available). Example JSON output: [example.json](bin/example.json).
59+
4960
## Tests Conducted
5061

5162
* **[fio](https://github.com/axboe/fio)** - the most comprehensive I/O testing software available, fio grants the ability to evaluate disk performance in a variety of methods with a variety of options. Four random read and write fio disk tests are conducted as part of this script with 4k, 64k, 512k, and 1m block sizes. The tests are designed to evaluate disk throughput in near-real world (using random) scenarios with a 50/50 split (50% reads and 50% writes per test).

Diff for: bin/example.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"version": "v2022-08-15",
3+
"arch": "x64",
4+
"ipv4": true,
5+
"ipv6": false,
6+
"uptime": 3916629.77,
7+
"cpu": {
8+
"model": "Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz",
9+
"cores": 12,
10+
"freq": "4000.093 MHz"
11+
},
12+
"aes": true,
13+
"virt": true,
14+
"ram": 32720272,
15+
"swap": 41904120,
16+
"disk": 47170290544,
17+
"distro": "Ubuntu 20.04.4 LTS",
18+
"kernel": "5.4.0-120-generic",
19+
"fio": [
20+
["4k", 154305, 38576, 154712, 38678, 309017, 77254],
21+
["64k", 210851, 3294, 211961, 3311, 422812, 6605],
22+
["512k", 222221, 434, 234028, 457, 456249, 891],
23+
["1m", 227198, 221, 242330, 236, 469528, 457]
24+
],
25+
"iperf": [
26+
["IPv4", "Clouvider", "London, UK (10G)", "128 Mbits/sec", "65.4 Mbits/sec"],
27+
["IPv4", "Online.net", "Paris, FR (10G)", "116 Mbits/sec", "busy "],
28+
["IPv4", "Clouvider", "NYC, NY, US (10G)", "140 Mbits/sec", "97.1 Mbits/sec"]
29+
],
30+
"geekbench": [
31+
[4, 5449, 24198, "https://browser.geekbench.com/v4/cpu/16602397"],
32+
[5, 1170, 5999, "https://browser.geekbench.com/v5/cpu/16636699"]
33+
]
34+
}

Diff for: yabs.sh

+69-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Yet Another Bench Script by Mason Rowe
4-
# Initial Oct 2019; Last update Jun 2022
4+
# Initial Oct 2019; Last update Aug 2022
55
#
66
# Disclaimer: This project is a work in progress. Any errors or suggestions should be
77
# relayed to me via the GitHub project page linked below.
@@ -12,10 +12,11 @@
1212
# performance via fio. The script is designed to not require any dependencies
1313
# - either compiled or installed - nor admin privileges to run.
1414
#
15+
YABS_VERSION="v2022-08-15"
1516

1617
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
1718
echo -e '# Yet-Another-Bench-Script #'
18-
echo -e '# v2022-06-11 #'
19+
echo -e '# '$YABS_VERSION' #'
1920
echo -e '# https://github.com/masonr/yet-another-bench-script #'
2021
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
2122

@@ -56,11 +57,11 @@ else
5657
fi
5758

5859
# flags to skip certain performance tests
59-
unset PREFER_BIN SKIP_FIO SKIP_IPERF SKIP_GEEKBENCH PRINT_HELP REDUCE_NET GEEKBENCH_4 GEEKBENCH_5 DD_FALLBACK IPERF_DL_FAIL
60+
unset PREFER_BIN SKIP_FIO SKIP_IPERF SKIP_GEEKBENCH PRINT_HELP REDUCE_NET GEEKBENCH_4 GEEKBENCH_5 DD_FALLBACK IPERF_DL_FAIL JSON_SEND JSON_RESULT
6061
GEEKBENCH_5="True" # gb5 test enabled by default
6162

6263
# get any arguments that were passed to the script and set the associated skip flags (if applicable)
63-
while getopts 'bfdighr49' flag; do
64+
while getopts 'bfdighr49j:' flag; do
6465
case "${flag}" in
6566
b) PREFER_BIN="True" ;;
6667
f) SKIP_FIO="True" ;;
@@ -71,6 +72,7 @@ while getopts 'bfdighr49' flag; do
7172
r) REDUCE_NET="True" ;;
7273
4) GEEKBENCH_4="True" && unset GEEKBENCH_5 ;;
7374
9) GEEKBENCH_4="True" && GEEKBENCH_5="True" ;;
75+
j) JSON_SEND=${OPTARG} ;;
7476
*) exit 1 ;;
7577
esac
7678
done
@@ -96,9 +98,9 @@ if [ ! -z "$PRINT_HELP" ]; then
9698
echo -e
9799
echo -e "Usage: ./yabs.sh [-flags]"
98100
echo -e " curl -sL yabs.sh | bash"
99-
echo -e " curl -sL yabs.sh | bash -s -- -{bfdighr49}"
101+
echo -e " curl -sL yabs.sh | bash -s -- -{bfdighr49j}"
100102
echo -e " wget -qO- yabs.sh | bash"
101-
echo -e " wget -qO- yabs.sh | bash -s -- -{bfdighr49}"
103+
echo -e " wget -qO- yabs.sh | bash -s -- -{bfdighr49j}"
102104
echo -e
103105
echo -e "Flags:"
104106
echo -e " -b : prefer pre-compiled binaries from repo over local packages"
@@ -112,6 +114,7 @@ if [ ! -z "$PRINT_HELP" ]; then
112114
echo -e " to lessen bandwidth usage"
113115
echo -e " -4 : use geekbench 4 instead of geekbench 5"
114116
echo -e " -9 : use both geekbench 4 AND geekbench 5"
117+
echo -e " -j <url> : send jsonified YABS results to URL"
115118
echo -e
116119
echo -e "Detected Arch: $ARCH"
117120
echo -e
@@ -138,6 +141,10 @@ if [ ! -z "$PRINT_HELP" ]; then
138141
[[ ! -z $IPV6_CHECK ]] && echo -e " IPv6 connected" ||
139142
echo -e " IPv6 not connected"
140143
echo -e
144+
echo -e "Sending JSON Results:"
145+
[[ ! -z $JSON_SEND ]] && echo -e " TRUE ($JSON_SEND)" ||
146+
echo -e " FALSE"
147+
echo -e
141148
echo -e "Exiting..."
142149
143150
exit 0
@@ -210,18 +217,32 @@ echo -e "AES-NI : $CPU_AES"
210217
CPU_VIRT=$(cat /proc/cpuinfo | grep 'vmx\|svm')
211218
[[ -z "$CPU_VIRT" ]] && CPU_VIRT="\xE2\x9D\x8C Disabled" || CPU_VIRT="\xE2\x9C\x94 Enabled"
212219
echo -e "VM-x/AMD-V : $CPU_VIRT"
213-
TOTAL_RAM=$(format_size $(free | awk 'NR==2 {print $2}'))
220+
TOTAL_RAM_RAW=$(free | awk 'NR==2 {print $2}')
221+
TOTAL_RAM=$(format_size $TOTAL_RAM_RAW)
214222
echo -e "RAM : $TOTAL_RAM"
215-
TOTAL_SWAP=$(format_size $(free | grep Swap | awk '{ print $2 }'))
223+
TOTAL_SWAP_RAW=$(free | grep Swap | awk '{ print $2 }')
224+
TOTAL_SWAP=$(format_size $TOTAL_SWAP_RAW)
216225
echo -e "Swap : $TOTAL_SWAP"
217226
# total disk size is calculated by adding all partitions of the types listed below (after the -t flags)
218-
TOTAL_DISK=$(format_size $(df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $2 }'))
227+
TOTAL_DISK_RAW=$(df -t simfs -t ext2 -t ext3 -t ext4 -t btrfs -t xfs -t vfat -t ntfs -t swap --total 2>/dev/null | grep total | awk '{ print $2 }')
228+
TOTAL_DISK=$(format_size $TOTAL_DISK_RAW)
219229
echo -e "Disk : $TOTAL_DISK"
220230
DISTRO=$(grep 'PRETTY_NAME' /etc/os-release | cut -d '"' -f 2 )
221231
echo -e "Distro : $DISTRO"
222232
KERNEL=$(uname -r)
223233
echo -e "Kernel : $KERNEL"
224234
235+
if [ ! -z $JSON_SEND ]; then
236+
UPTIME_S=$(awk '{print $1}' /proc/uptime)
237+
IPV4=$([ ! -z $IPV4_CHECK ] && echo "true" || echo "false")
238+
IPV6=$([ ! -z $IPV6_CHECK ] && echo "true" || echo "false")
239+
AES=$([[ "$CPU_AES" = *Enabled* ]] && echo "true" || echo "false")
240+
VIRT=$([[ "$CPU_VIRT" = *Enabled* ]] && echo "true" || echo "false")
241+
JSON_RESULT='{"version":"'$YABS_VERSION'","arch":"'$ARCH'","ipv4":'$IPV4',"ipv6":'$IPV6',"uptime":'$UPTIME_S',"cpu":{"model":"'$CPU_PROC'"'
242+
JSON_RESULT+=',"cores":'$CPU_CORES',"freq":"'$CPU_FREQ'"},"aes":'$AES',"virt":'$VIRT',"ram":'$TOTAL_RAM_RAW',"swap":'$TOTAL_SWAP_RAW','
243+
JSON_RESULT+='"disk":'$TOTAL_DISK_RAW',"distro":"'$DISTRO'","kernel":"'$KERNEL'"'
244+
fi
245+
225246
# create a directory in the same location that the script is being run to temporarily store YABS-related files
226247
DATE=`date -Iseconds | sed -e "s/:/_/g"`
227248
YABS_PATH=./$DATE
@@ -341,12 +362,16 @@ function disk_test {
341362
DISK_TEST=$(timeout 35 $FIO_CMD --name=rand_rw_$BS --ioengine=libaio --rw=randrw --rwmixread=50 --bs=$BS --iodepth=64 --numjobs=2 --size=$FIO_SIZE --runtime=30 --gtod_reduce=1 --direct=1 --filename=$DISK_PATH/test.fio --group_reporting --minimal 2> /dev/null | grep rand_rw_$BS)
342363
DISK_IOPS_R=$(echo $DISK_TEST | awk -F';' '{print $8}')
343364
DISK_IOPS_W=$(echo $DISK_TEST | awk -F';' '{print $49}')
344-
DISK_IOPS=$(format_iops $(awk -v a="$DISK_IOPS_R" -v b="$DISK_IOPS_W" 'BEGIN { print a + b }'))
345-
DISK_IOPS_R=$(format_iops $DISK_IOPS_R)
346-
DISK_IOPS_W=$(format_iops $DISK_IOPS_W)
365+
DISK_IOPS=$(awk -v a="$DISK_IOPS_R" -v b="$DISK_IOPS_W" 'BEGIN { print a + b }')
347366
DISK_TEST_R=$(echo $DISK_TEST | awk -F';' '{print $7}')
348367
DISK_TEST_W=$(echo $DISK_TEST | awk -F';' '{print $48}')
349-
DISK_TEST=$(format_speed $(awk -v a="$DISK_TEST_R" -v b="$DISK_TEST_W" 'BEGIN { print a + b }'))
368+
DISK_TEST=$(awk -v a="$DISK_TEST_R" -v b="$DISK_TEST_W" 'BEGIN { print a + b }')
369+
DISK_RESULTS_RAW+=( "$DISK_TEST" "$DISK_TEST_R" "$DISK_TEST_W" "$DISK_IOPS" "$DISK_IOPS_R" "$DISK_IOPS_W" )
370+
371+
DISK_IOPS=$(format_iops $DISK_IOPS)
372+
DISK_IOPS_R=$(format_iops $DISK_IOPS_R)
373+
DISK_IOPS_W=$(format_iops $DISK_IOPS_W)
374+
DISK_TEST=$(format_speed $DISK_TEST)
350375
DISK_TEST_R=$(format_speed $DISK_TEST_R)
351376
DISK_TEST_W=$(format_speed $DISK_TEST_W)
352377
@@ -479,7 +504,7 @@ elif [ -z "$SKIP_FIO" ]; then
479504
echo -en "\r\033[0K"
480505

481506
# init global array to store disk performance values
482-
declare -a DISK_RESULTS
507+
declare -a DISK_RESULTS DISK_RESULTS_RAW
483508
# disk block sizes to evaluate
484509
BLOCK_SIZES=( "4k" "64k" "512k" "1m" )
485510

@@ -517,6 +542,7 @@ elif [ -z "$SKIP_FIO" ]; then
517542
printf "%-6s | %-11s | %-11s | %-11s | %-6.2f %-4s\n" "Write" "${DISK_WRITE_TEST_RES[0]}" "${DISK_WRITE_TEST_RES[1]}" "${DISK_WRITE_TEST_RES[2]}" "${DISK_WRITE_TEST_AVG}" "${DISK_WRITE_TEST_UNIT}"
518543
printf "%-6s | %-11s | %-11s | %-11s | %-6.2f %-4s\n" "Read" "${DISK_READ_TEST_RES[0]}" "${DISK_READ_TEST_RES[1]}" "${DISK_READ_TEST_RES[2]}" "${DISK_READ_TEST_AVG}" "${DISK_READ_TEST_UNIT}"
519544
else # fio tests completed successfully, print results
545+
[[ ! -z $JSON_SEND ]] && JSON_RESULT+=',"fio":['
520546
DISK_RESULTS_NUM=$(expr ${#DISK_RESULTS[@]} / 6)
521547
DISK_COUNT=0
522548

@@ -531,8 +557,15 @@ elif [ -z "$SKIP_FIO" ]; then
531557
printf "%-10s | %-11s %8s | %-11s %8s\n" "Read" "${DISK_RESULTS[DISK_COUNT*6+1]}" "(${DISK_RESULTS[DISK_COUNT*6+4]})" "${DISK_RESULTS[(DISK_COUNT+1)*6+1]}" "(${DISK_RESULTS[(DISK_COUNT+1)*6+4]})"
532558
printf "%-10s | %-11s %8s | %-11s %8s\n" "Write" "${DISK_RESULTS[DISK_COUNT*6+2]}" "(${DISK_RESULTS[DISK_COUNT*6+5]})" "${DISK_RESULTS[(DISK_COUNT+1)*6+2]}" "(${DISK_RESULTS[(DISK_COUNT+1)*6+5]})"
533559
printf "%-10s | %-11s %8s | %-11s %8s\n" "Total" "${DISK_RESULTS[DISK_COUNT*6]}" "(${DISK_RESULTS[DISK_COUNT*6+3]})" "${DISK_RESULTS[(DISK_COUNT+1)*6]}" "(${DISK_RESULTS[(DISK_COUNT+1)*6+3]})"
560+
if [ ! -z $JSON_SEND ]; then
561+
JSON_RESULT+='["'${BLOCK_SIZES[DISK_COUNT]}'",'${DISK_RESULTS_RAW[DISK_COUNT*6+1]}','${DISK_RESULTS_RAW[DISK_COUNT*6+4]}','${DISK_RESULTS_RAW[DISK_COUNT*6+2]}
562+
JSON_RESULT+=','${DISK_RESULTS_RAW[DISK_COUNT*6+5]}','${DISK_RESULTS_RAW[DISK_COUNT*6]}','${DISK_RESULTS_RAW[DISK_COUNT*6+3]}'],'
563+
JSON_RESULT+='["'${BLOCK_SIZES[DISK_COUNT+1]}'",'${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+1]}','${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+4]}','${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+2]}
564+
JSON_RESULT+=','${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+5]}','${DISK_RESULTS_RAW[(DISK_COUNT+1)*6]}','${DISK_RESULTS_RAW[(DISK_COUNT+1)*6+3]}'],'
565+
fi
534566
DISK_COUNT=$(expr $DISK_COUNT + 2)
535567
done
568+
[[ ! -z $JSON_SEND ]] && JSON_RESULT=${JSON_RESULT::${#JSON_RESULT}-1} && JSON_RESULT+=']'
536569
fi
537570
fi
538571

@@ -641,6 +674,9 @@ function launch_iperf {
641674
[[ -z $IPERF_RECVRESULT_VAL || "$IPERF_RECVRESULT_VAL" == *"0.00"* ]] && IPERF_RECVRESULT_VAL="busy" && IPERF_RECVRESULT_UNIT=""
642675
# print the speed results for the iperf location currently being evaluated
643676
printf "%-15s | %-25s | %-15s | %-15s\n" "${IPERF_LOCS[i*5+2]}" "${IPERF_LOCS[i*5+3]}" "$IPERF_SENDRESULT_VAL $IPERF_SENDRESULT_UNIT" "$IPERF_RECVRESULT_VAL $IPERF_RECVRESULT_UNIT"
677+
if [ ! -z $JSON_SEND ]; then
678+
JSON_RESULT+='["'$MODE'","'${IPERF_LOCS[i*5+2]}'","'${IPERF_LOCS[i*5+3]}'","'$IPERF_SENDRESULT_VAL' '$IPERF_SENDRESULT_UNIT'","'$IPERF_RECVRESULT_VAL' '$IPERF_RECVRESULT_UNIT'"],'
679+
fi
644680
fi
645681
done
646682
}
@@ -704,10 +740,12 @@ if [ -z "$SKIP_IPERF" ]; then
704740
IPERF_LOCS_NUM=$((IPERF_LOCS_NUM / 5))
705741

706742
if [ -z "$IPERF_DL_FAIL" ]; then
743+
[[ ! -z $JSON_SEND ]] && JSON_RESULT+=',"iperf":['
707744
# check if the host has IPv4 connectivity, if so, run iperf3 IPv4 tests
708745
[ ! -z "$IPV4_CHECK" ] && launch_iperf "IPv4"
709746
# check if the host has IPv6 connectivity, if so, run iperf3 IPv6 tests
710747
[ ! -z "$IPV6_CHECK" ] && launch_iperf "IPv6"
748+
[[ ! -z $JSON_SEND ]] && JSON_RESULT=${JSON_RESULT::${#JSON_RESULT}-1} && JSON_RESULT+=']'
711749
else
712750
echo -e "\niperf3 binary download failed. Skipping iperf network tests..."
713751
fi
@@ -809,25 +847,42 @@ function launch_geekbench {
809847
printf "%-15s | %-30s\n" "Multi Core" "$GEEKBENCH_SCORES_MULTI"
810848
printf "%-15s | %-30s\n" "Full Test" "$GEEKBENCH_URL"
811849

850+
if [ ! -z $JSON_SEND ]; then
851+
JSON_RESULT+='['$VERSION','$GEEKBENCH_SCORES_SINGLE','$GEEKBENCH_SCORES_MULTI',"'$GEEKBENCH_URL'"],'
852+
fi
853+
812854
# write the geekbench claim URL to a file so the user can add the results to their profile (if desired)
813855
[ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" >> geekbench_claim.url 2> /dev/null
814856
fi
815857
}
816858

817859
# if the skip geekbench flag was set, skip the system performance test, otherwise test system performance
818860
if [ -z "$SKIP_GEEKBENCH" ]; then
861+
[[ ! -z $JSON_SEND ]] && JSON_RESULT+=',"geekbench":['
819862
if [[ $GEEKBENCH_4 == *True* ]]; then
820863
launch_geekbench 4
821864
fi
822865

823866
if [[ $GEEKBENCH_5 == *True* ]]; then
824867
launch_geekbench 5
825868
fi
869+
[[ ! -z $JSON_SEND ]] && JSON_RESULT=${JSON_RESULT::${#JSON_RESULT}-1} && JSON_RESULT+=']'
826870
fi
827871

828872
# finished all tests, clean up all YABS files and exit
829873
echo -e
830874
rm -rf $YABS_PATH
831875

876+
# send json results
877+
if [ ! -z $JSON_SEND ]; then
878+
JSON_RESULT+='}'
879+
880+
if [[ ! -z $LOCAL_CURL ]]; then
881+
curl -s -H "Content-Type:application/json" -X POST --data ''"$JSON_RESULT"'' $JSON_SEND
882+
else
883+
wget -qO- --post-data=''"$JSON_RESULT"'' --header='Content-Type:application/json' $JSON_SEND
884+
fi
885+
fi
886+
832887
# reset locale settings
833888
unset LC_ALL

0 commit comments

Comments
 (0)