perf: a random write buffered fio perf test
[xfstests-dev.git] / randomize.awk
1 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License as
5 # published by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it would be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write the Free Software Foundation,
14 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
15 #
16
17 # randomize stdin.
18
19 function randomize(array, N) {
20   for(i = 0; i < N; i++) {
21     j = int(rand()*N)
22     if ( i != j) {
23     tmp = array[i]
24     array[i] = array[j]
25     array[j] = tmp
26     }
27   }
28 return
29 }
30
31 {
32     srand()
33     for (i = 0; i < NF; i++ ) array[i] = $(i+1)
34     randomize(array, NF)
35     for (i = 0; i < NF; i++) printf("%s ", array[i])
36 }
37