cassandraTestWriteLoop.sh 2.3 KB
Newer Older
S
Shuduo Sang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/bin/bash

DATA_DIR=/mnt/root/testdata
NUM_LOOP=1
NUM_OF_FILES=100

rowsPerRequest=(1 10 50 100 500 1000 2000)

function printTo {
  if $verbose ; then
    echo $1
  fi
}

function runTest {
S
Shuduo Sang 已提交
16
  declare -A avgRPR
S
Shuduo Sang 已提交
17

S
Shuduo Sang 已提交
18 19
  for r in ${!rowsPerRequest[@]}; do
    for c in `seq 1 $clients`; do
S
Shuduo Sang 已提交
20
      avgRPR[$r,$c]=0
S
Shuduo Sang 已提交
21
    done
S
Shuduo Sang 已提交
22 23
  done

S
Shuduo Sang 已提交
24
  for r in ${!rowsPerRequest[@]}; do
S
Shuduo Sang 已提交
25 26
    for c in `seq 1 $clients`; do
      totalRPR=0
S
Shuduo Sang 已提交
27
      OUT_FILE=cassandraWrite-rows${rowsPerRequest[$r]}-clients$c.out
S
Shuduo Sang 已提交
28 29 30 31
      for i in `seq 1 $NUM_LOOP`; do
        printTo "loop i:$i, java -jar $CAS_TEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \
            -datadir $DATA_DIR \
            -numofFiles $NUM_OF_FILES \
S
Shuduo Sang 已提交
32
            -rowsperrequest ${rowsPerRequest[$r]} \
S
Shuduo Sang 已提交
33 34 35 36 37
            -writeclients $c \
            -conf $CAS_TEST_DIR/application.conf"
        java -jar $CAS_TEST_DIR/cassandratest/target/cassandratest-1.0-SNAPSHOT-jar-with-dependencies.jar \
            -datadir $DATA_DIR \
            -numofFiles $NUM_OF_FILES \
S
Shuduo Sang 已提交
38
            -rowsperrequest ${rowsPerRequest[$r]} \
S
Shuduo Sang 已提交
39 40
            -writeclients $c \
            -conf $CAS_TEST_DIR/application.conf \
S
Shuduo Sang 已提交
41
            2>&1 | tee $OUT_FILE
S
Shuduo Sang 已提交
42 43
        RPR=`cat $OUT_FILE | grep "insertation speed:" | awk '{print $(NF-1)}'`
        totalRPR=`echo "scale=4; $totalRPR + $RPR" | bc`
S
Shuduo Sang 已提交
44
        printTo "r:$r rows:${rowsPerRequest[$r]}, clients:$c, i:$i RPR:$RPR"
S
Shuduo Sang 已提交
45
      done
S
Shuduo Sang 已提交
46 47
      avgRPR[$r,$c]=`echo "scale=4; $totalRPR / $NUM_LOOP" | bc`
      printTo "r:$r c:$c avgRPR:${avgRPR[$r,$c]}"
S
Shuduo Sang 已提交
48
    done
S
Shuduo Sang 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62
  done

  printf "R/R, "
  for c in `seq 1 $clients`; do
    if [ "$c" == "1" ]; then
      printf "$c client, "
    else
      printf "$c clients, "
    fi
  done
  printf "\n"

  for r in ${!rowsPerRequest[@]}; do
    printf "${rowsPerRequest[$r]}, "
S
Shuduo Sang 已提交
63
    for c in `seq 1 $clients`; do
S
Shuduo Sang 已提交
64
      printf "${avgRPR[$r,$c]}, "
S
Shuduo Sang 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    done
    printf "\n"
  done
}

################ Main ################

verbose=false
clients=1

while : ; do
  case $1 in
    -v)
      verbose=true
      shift ;;

S
Shuduo Sang 已提交
81 82 83 84
    -n)
      NUM_LOOP=$2
      shift 2;;

S
Shuduo Sang 已提交
85 86 87
    -c)
      clients=$2
      shift 2;;
S
Shuduo Sang 已提交
88

S
Shuduo Sang 已提交
89 90 91 92 93 94 95 96 97 98 99 100 101
    *)
      break ;;
  esac
done

printTo "Cassandra Test begin.."

WORK_DIR=/mnt/root/TDengine
CAS_TEST_DIR=$WORK_DIR/tests/comparisonTest/cassandra

runTest

printTo "Cassandra Test done!"