]> git.proxmox.com Git - ceph.git/blob - ceph/src/erasure-code/jerasure/gf-complete/tools/time_tool.sh
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / erasure-code / jerasure / gf-complete / tools / time_tool.sh
1 # time_tool.sh - Shell script to test various timings.
2 # This is a rough tester -- its job is to work quickly rather than precisely.
3 # (Jim Plank)
4
5 #!/bin/sh
6
7 if [ $# -lt 3 ]; then
8 echo 'usage sh time_tool.sh M|D|R|B w method' >&2
9 exit 1
10 fi
11
12 op=$1
13 w=$2
14
15 shift ; shift
16
17 method="$*"
18
19 if [ $op != M -a $op != D -a $op != R -a $op != B ]; then
20 echo 'usage sh time_tool.sh M|D|R|B w method' >&2
21 echo 'You have to specify a test: ' >&2
22 echo ' M=Multiplication' >&2
23 echo ' D=Division' >&2
24 echo ' R=Regions' >&2
25 echo ' B=Best-Region' >&2
26 exit 1
27 fi
28
29 # First, use a 16K buffer to test the performance of single multiplies.
30
31 fac=`echo $w | awk '{ n = $1; while (n != 0 && n%2==0) n /= 2; print n }'`
32 if [ $fac -eq 0 ]; then
33 echo 'usage sh time_tool.sh M|D|R|B w method' >&2
34 echo 'Bad w' >&2
35 exit 1
36 fi
37
38 bsize=16384
39 bsize=`echo $bsize $fac | awk '{ print $1 * $2 }'`
40
41 if [ `./gf_time $w M -1 $bsize 1 $method 2>&1 | wc | awk '{ print $1 }'` -gt 2 ]; then
42 echo 'usage sh time_tool.sh w method' >&2
43 echo "Bad method"
44 exit 1
45 fi
46
47 if [ $op = M -o $op = D ]; then
48 iter=1
49 c1=`./gf_time $w $op -1 $bsize $iter $method`
50 t=`echo $c1 | awk '{ printf "%d\n", $4*100 }'`
51 s=`echo $c1 | awk '{ print $8 }'`
52 bs=$s
53
54 while [ $t -lt 1 ]; do
55 bs=$s
56 iter=`echo $iter | awk '{ print $1*2 }'`
57 c1=`./gf_time $w $op -1 $bsize $iter $method`
58 t=`echo $c1 | awk '{ printf "%d\n", $4*100 }'`
59 s=`echo $c1 | awk '{ print $8 }'`
60 done
61
62 echo $op $bs | awk '{ printf "%s speed (MB/s): %8.2lf W-Method: ", $1, $2 }'
63 echo $w $method
64 exit 0
65 fi
66
67 bsize=16384
68 bsize=`echo $bsize $fac | awk '{ print $1 * $2 }'`
69
70 best=0
71 while [ $bsize -le 4194304 ]; do
72 iter=1
73 c1=`./gf_time $w G -1 $bsize $iter $method`
74 t=`echo $c1 | awk '{ printf "%d\n", $6*500 }'`
75 s=`echo $c1 | awk '{ print $10 }'`
76 bs=$s
77
78 while [ $t -lt 1 ]; do
79 bs=$s
80 iter=`echo $iter | awk '{ print $1*2 }'`
81 c1=`./gf_time $w G -1 $bsize $iter $method`
82 t=`echo $c1 | awk '{ printf "%d\n", $6*500 }'`
83 s=`echo $c1 | awk '{ print $10 }'`
84 done
85 if [ $bsize -lt 1048576 ]; then
86 str=`echo $bsize | awk '{ printf "%3dK\n", $1/1024 }'`
87 else
88 str=`echo $bsize | awk '{ printf "%3dM\n", $1/1024/1024 }'`
89 fi
90 if [ $op = R ]; then
91 echo $str $bs | awk '{ printf "Region Buffer-Size: %4s (MB/s): %8.2lf W-Method: ", $1, $2 }'
92 echo $w $method
93 fi
94 best=`echo $best $bs | awk '{ print ($1 > $2) ? $1 : $2 }'`
95 bsize=`echo $bsize | awk '{ print $1 * 2 }'`
96 done
97 echo $best | awk '{ printf "Region Best (MB/s): %8.2lf W-Method: ", $1 }'
98 echo $w $method