github.com/true-sqn/fabric@v2.1.1+incompatible/core/ledger/kvledger/benchmark/scripts/runbenchmarks.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright IBM Corp. All Rights Reserved.
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  source ./benchmarks.sh
     9  
    10  ########################################################################################################
    11  # This shell script contains a series of benchmark tests
    12  ########################################################################################################
    13  function runWithDefaultParams {
    14    source $PARAM_FILE  
    15    if [[ $RunWithDefaultParams = "true" ]]
    16    then
    17      rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    18    fi
    19  }
    20  
    21  function varyNumParallelTxPerChain {
    22      source $PARAM_FILE    
    23      for v in "${ArrayNumParallelTxPerChain[@]}"
    24      do
    25          NumParallelTxPerChain=$v
    26          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    27      done
    28  }
    29  
    30  function varyNumChains {
    31      source $PARAM_FILE
    32      for v in "${ArrayNumChains[@]}"
    33      do
    34          NumChains=$v
    35          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    36      done
    37  }
    38  
    39  function varyNumWritesPerTx {
    40      source $PARAM_FILE
    41      for v in "${ArrayNumWritesPerTx[@]}"
    42      do
    43          NumWritesPerTx=$v
    44          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    45      done
    46  }
    47  
    48  function varyNumReadsPerTx {
    49      source $PARAM_FILE
    50      for v in "${ArrayNumReadsPerTx[@]}"
    51      do
    52          NumReadsPerTx=$v
    53          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    54      done
    55  }
    56  
    57  function varyKVSize {
    58      source $PARAM_FILE
    59      for v in "${ArrayKVSize[@]}"
    60      do
    61          KVSize=$v
    62          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    63      done
    64  }
    65  
    66  function varyBatchSize {
    67      source $PARAM_FILE
    68      for v in "${ArrayBatchSize[@]}"
    69      do
    70          BatchSize=$v
    71          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    72      done
    73  }
    74  
    75  function varyNumTxs {
    76      source $PARAM_FILE
    77      for v in "${ArrayNumTxs[@]}"
    78      do
    79          NumTotalTx=$v
    80          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    81      done
    82  }
    83  
    84  function runLargeDataExperiment {
    85    source $PARAM_FILE
    86    if [[ $RunLargeDataExperiment = "true" ]]
    87    then    
    88      NumKVs=10000000
    89      NumTotalTx=10000000
    90          rm -rf $DataDir;upCouchDB;runInsertTxs;runReadWriteTxs
    91    fi
    92  }
    93  
    94  function usage () {
    95      printf "Usage: ./runbenchmarks.sh -f parameter_file_name"
    96  }
    97  
    98  PARAM_FILE=""
    99  
   100  while getopts ":f:" opt; do
   101    case $opt in
   102      f)
   103        printf "Parameter file: $OPTARG\n"
   104        PARAM_FILE=$OPTARG;;
   105      \?)
   106        printf "Error: invalid parameter -$OPTARG!"  >> /dev/stderr
   107        usage
   108        exit 1;;
   109    esac
   110  done
   111  
   112  if [ ! $PARAM_FILE ]
   113  then
   114    printf "Error: No Parameter file given!"  >> /dev/stderr
   115    usage
   116    exit 1
   117  fi
   118  
   119  ### Run tests
   120    runWithDefaultParams
   121    varyNumParallelTxPerChain
   122    varyNumChains
   123    varyNumWritesPerTx
   124    varyNumReadsPerTx
   125    varyKVSize
   126    varyBatchSize
   127    varyNumTxs
   128    runLargeDataExperiment