Merge branch 'master' of git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev
[xfstests-dev.git] / common.dbench
1 ##/bin/bash
2 #
3 # Copyright (c) 2002-2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 #
18
19 #check dbench is installed
20 if [ "`whereis dbench`" == "dbench:" ]; then
21         echo $0 error dbench not installed.
22         exit
23 fi
24
25 _run_dbench()
26 {
27         mkdir ./dbench || exit 1
28         cd dbench
29         dbench -x $1
30         status=$?
31         cd ..
32         rm -fr ./dbench
33         [ $status -ne 0 ] && exit 1
34 }
35
36 #
37 # Sample dbench output:
38 # "Throughput 40.6701 MB/sec (NB=50.8376 MB/sec  406.701 MBit/sec)"
39
40
41 # Output for a single-shot dbench run.
42 _format_header()
43 {
44         printf "%8s, %s\n" clients MB/sec
45 }
46 _filter_dbench()
47 {
48         clients=$1
49         perl -ne 'm/Throughput (\S+) MB\/sec/ &&
50                         { printf "%8u, %s\n", '$clients', $1 }'
51 }
52
53 # Output for a "multipass" dbench run.
54 _format_header_multipass()
55 {
56         while [ $# -gt 1 ]; do
57                 printf "%4s::MB/sec," $1
58                 shift
59         done
60         printf "%4s::MB/sec\n" $1
61 }
62 _filter_dbench_multipass()
63 {
64         perl -ne '
65         if (m/Throughput (\S+) MB\/sec/) {
66                 $results[$count++] = $1;
67         }
68         END {   for ($i = 0; $i < $count - 1; $i++) {
69                         printf "%12.3f,", $results[$i];
70                 }
71                 printf "%12.3f\n", $results[$count-1];
72         }'
73 }