-
Notifications
You must be signed in to change notification settings - Fork 5
/
get-gb-scores.sh
executable file
·43 lines (35 loc) · 1.11 KB
/
get-gb-scores.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
if [[ $# -eq 0 ]]; then
echo "$0 <query>"
exit 1
fi
query="$@"
maxPages=50
queryEncoded=$(node -p "encodeURIComponent('$query')")
search() {
local i=1
while [[ $i -le $maxPages ]]
do
echo -ne " -> Downloading page $i\033[0K\r" 1>&2
result=$(curl -s https://browser.geekbench.com/v4/cpu/search\?utf8=%E2%9C%93\&page\=${i}\&q\=$queryEncoded)
echo "$result"
if echo "$result" | grep -q "did not match any Geekbench 4 results"; then
echo 1>&2
break
fi
i=$((i + 1))
done
}
printf "Average Geekbench 4 scores for \`${query}\`:\n\n"
search | grep -A 1 "<td class='score'>" | grep '^\d\d\d\+$' | paste -sd " " - | awk '\
BEGIN {count = 0; single = 0; multi = 0; debug=0}\
{for (i = 1; i <= NF; i=i+2) { single += $i; count++; } }\
{for (i = 2; i <= NF; i=i+2) { multi += $i; } }\
debug==1 {for (i=1; i <= NF; i=i+2) print $i}\
debug==1 {print "==================="}\
debug==1 {for (i=2; i <= NF; i=i+2) print $i}\
END {\
print "Single-Core Score:\t" single/count;\
print "Multi-Core Score:\t" multi/count;\
print "\nScores are based on " count " results."\
}'