-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathupdate-perf.sh
executable file
·83 lines (64 loc) · 2.27 KB
/
update-perf.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
set -ex
set -o pipefail
version=""
storage_format=""
sed_cmd_i=""
start_marker=""
end_marker=""
dest_file=""
os_type="darwin"
sql_reference_dir="packages/dolt/content/reference/sql/benchmarks"
start_template='<!-- START_%s_%s_RESULTS_TABLE -->'
end_template='<!-- END_%s_%s_RESULTS_TABLE -->'
if [ "$#" -ne 4 ]; then
echo "usage: update-perf.sh <version> <format> <type: latency/correctness> <filepath>"
exit 1;
fi
version="$1"
storage_format="$2"
type="$3"
new_table="$4"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
os_type="linux"
fi
if [[ "$storage_format" != "__DOLT__" ]]; then
echo "only __DOLT__ supported in docs"
exit 1
fi
if [ "$type" == "latency" ]
then
dest_file="$sql_reference_dir/latency.md"
# update the version
if [ "$os_type" == "linux" ]
then
sed -i 's/The Dolt version is `'".*"'`/The Dolt version is `'"$version"'`/' "$dest_file"
else
sed -i '' "s/The Dolt version is \\\`.*\\\`/The Dolt version is \\\`$version\\\`/" "$dest_file"
fi
start_marker=$(printf "$start_template" "$storage_format" "LATENCY")
end_marker=$(printf "$end_template" "$storage_format" "LATENCY")
else
dest_file="$sql_reference_dir/correctness.md"
# update the version
if [ "$os_type" == "linux" ]
then
sed -i 's/Here are Dolt'"'"'s sqllogictest results for version `'".*"'`./Here are Dolt'"'"'s sqllogictest results for version `'"$version"'`./' "$dest_file"
else
sed -i '' 's/Here are Dolt'"'"'s sqllogictest results for version `'".*"'`./Here are Dolt'"'"'s sqllogictest results for version `'"$version"'`./' "$dest_file"
fi
start_marker=$(printf "$start_template" "$storage_format" "CORRECTNESS")
end_marker=$(printf "$end_template" "$storage_format" "CORRECTNESS")
fi
# store in variable
updated=$(cat "$new_table")
updated_with_markers=$(printf "$start_marker\n$updated\n$end_marker\n")
echo "$updated_with_markers" > "$new_table"
# replace table in the proper file
if [ "$os_type" == "linux" ]
then
sed -e '/<!-- END_'"$storage_format"'/r '"$new_table"'' -e '/<!-- START_'"$storage_format"'/,/<!-- END_'"$storage_format"'/d' "$dest_file" > temp.md
else
sed -e '/\<!-- END_'"$storage_format"'/r '"$new_table"'' -e '/\<!-- START_'"$storage_format"'/,/\<!-- END_'"$storage_format"'/d' "$dest_file" > temp.md
fi
mv temp.md "$dest_file"