forked from ClickHouse/ClickBench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·28 lines (24 loc) · 891 Bytes
/
run.sh
File metadata and controls
executable file
·28 lines (24 loc) · 891 Bytes
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
#!/bin/bash
TRIES=3
QUERY_NUM=1
echo $1
cat queries.sql | while read -r query; do
sync
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
echo "$query" > /tmp/query.sql
echo -n "["
for i in $(seq 1 $TRIES); do
# 1. there will be two query result, one for creating table another for executing the select statement
# 2. each query contains a "Query took xxx seconds", we just grep these 2 lines
# 3. use sed to take the second line
# 4. use awk to take the number we want
RES=$(datafusion-cli -f create.sql /tmp/query.sql 2>&1 | grep "Elapsed" |sed -n 2p | awk '{ print $2 }')
[[ $RES != "" ]] && \
echo -n "$RES" || \
echo -n "null"
[[ "$i" != $TRIES ]] && echo -n ", "
echo "${QUERY_NUM},${i},${RES}" >> result.csv
done
echo "],"
QUERY_NUM=$((QUERY_NUM + 1))
done