summaryrefslogtreecommitdiffstats
path: root/perf-framework/parallel_create
diff options
context:
space:
mode:
authorRahul C S <rahulcs@redhat.com>2012-02-17 17:23:28 +0530
committerRahul C S <rahulcs@redhat.com>2012-02-17 17:24:19 +0530
commitdb468693ef5faa294d9bc3cd3c5d70c0d99d488b (patch)
treef552d0a8e88304dba5038eac670a5c7afe3c267e /perf-framework/parallel_create
parent01a77a1ae18d9add01f893e06e58191b065602e8 (diff)
Adding the performance framework to the qa repo
Change-Id: Ia7dbd82e9bb2e5e65e9345234ce34f8518a091ad Signed-off-by: Rahul C S <rahulcs@redhat.com>
Diffstat (limited to 'perf-framework/parallel_create')
-rwxr-xr-xperf-framework/parallel_create71
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 $@