diff options
author | Amar Tumballi <amarts@redhat.com> | 2012-02-18 10:36:44 -0800 |
---|---|---|
committer | Gerrit Code Review <root@dev.gluster.com> | 2012-02-18 10:36:44 -0800 |
commit | 6ed4ac470d7aaddd05ce179bc304ef688f5553aa (patch) | |
tree | 095187e0649d88c226563f41f19a6fba0b4a156e /perf-framework/parallel_create | |
parent | 4de9a1a4df6667a59dd36148167d7ea188c69831 (diff) | |
parent | db468693ef5faa294d9bc3cd3c5d70c0d99d488b (diff) |
Merge "Adding the performance framework to the qa repo"
Diffstat (limited to 'perf-framework/parallel_create')
-rwxr-xr-x | perf-framework/parallel_create | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/perf-framework/parallel_create b/perf-framework/parallel_create new file mode 100755 index 0000000..0bd9406 --- /dev/null +++ b/perf-framework/parallel_create @@ -0,0 +1,71 @@ +#!/bin/bash + +FILE_REPO="/mnt/perfmount/file_repo" +TEST=0 +DD_BS=512 +RAND_SCALE=20 + +function usage() +{ + echo "usage: $1 <thread_count> <file_count>" + exit 1 +} + +function create_files() +{ + tid=$1 + count=$2 + start=$((tid*count)) + + if [ $TEST -eq "1" ]; then + for ((i=0; i<${count}; i++)); do + outfile=$FILE_REPO/tid${tid}_file$((start+i)) + echo "dd if=/dev/urandom of=$outfile bs=1b count=$((RANDOM*20))" + done + else + for ((i=0; i<${count}; i++)); do + filesize=$((RANDOM*RAND_SCALE)) + dd_count=$((filesize/DD_BS)) + outfile=$FILE_REPO/tid${tid}_file$((start+i)) + dd if=/dev/zero of=$outfile bs=1b count=$dd_count > /dev/null 2>&1 + echo "$tid $i" + done + fi +} + +function Not_A_Number() +{ + echo $1$2 | grep ^[0-9]*$ > /dev/null + return $? +} + +function main() +{ + if [ $# -ne 2 ]; then + usage $0 + fi + + if ! Not_A_Number $1 $2; then + echo "Invalid input. Enter only numbers." + usage + fi + + if [ $2 -lt $1 ]; then + echo "Number of files cannot be less than number of threads" + usage $0 + fi + + mkdir -p $FILE_REPO + + nthr=$1 + fc=$2 + files_per_thr=$((fc/nthr)) + + for i in `seq 0 $((nthr-1))`; do + create_files $i $files_per_thr & + done + + wait +} + +main $@ |