-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark
executable file
·53 lines (41 loc) · 1.69 KB
/
benchmark
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
#!/bin/bash
if [ "$1" != "" ]; then
echo '# filename, treewidth, vertices, # bags TD, # bags NTD, time, bisection size'
for filename in $1/*.gr; do
td_file=${filename/.gr/.td}
# run algorithm
output=$(java -jar td-bisection.jar -g "$filename" -td "$td_file" 2>/dev/null)
exitcode=$?
if [ "$exitcode" != "0" ]; then
# echo "# error: ($filename)"
continue
fi
# parse time
timestr=$(echo "$output" | grep "Max Bisection time:")
time=${timestr:20:((${#timestr}-20))}
# parse bisection size
bsstr=$(echo "$output" | grep "Max Bisection size:")
bs=${bsstr:20:((${#bsstr}-20))}
# parse treewidth
twstr=$(echo "$output" | grep "Treewidth:")
treewidth=${twstr:11:((${#twstr}-11))}
# parse num vertices
vertexstr=$(echo "$output" | grep "Graph vertices:")
vertices=${vertexstr:16:((${#vertexstr}-16))}
# parse TD info
tdstr1=$(echo "$output" | grep " TD #bags:")
tdstr2=$(echo "$output" | grep "NTD #bags:")
tdbags=${tdstr1:11:((${#tdstr1}-11))}
ntdbags=${tdstr2:11:((${#tdstr2}-11))}
short_filename=$(basename $filename)
short_filename=${short_filename/.gr/}
safe_filename=${short_filename//,/_}
if [ "$(echo "$output" | grep "Warning: NTD is not optimal.")" != "" ]; then
# echo "#! $safe_filename, $treewidth, $vertices, $tdbags, $ntdbags, $time, $bs"
continue
fi
echo "$safe_filename, $treewidth, $vertices, $tdbags, $ntdbags, $time, $bs"
done
else
echo "Input folder (containing .gr and .td files) argument missing."
fi