generate-weights.sh 871 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. # Executes and replaces all benchmarks with the new weights
  3. SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
  4. STEPS=${1:-50}
  5. REPEAT=${2:-20}
  6. benchmark() {
  7. echo "Generating weights for $1..."
  8. start=`date +%s`
  9. ERROR=$($SCRIPT_DIR/../target/release/joystream-node benchmark \
  10. --pallet=$1 \
  11. --extrinsic=* \
  12. --chain=dev \
  13. --steps=$STEPS \
  14. --repeat=$REPEAT \
  15. --execution=wasm \
  16. --output=. 2>&1 > /dev/null)
  17. if [[ $ERROR != *"Error"* ]]; then
  18. end=`date +%s`
  19. mv $SCRIPT_DIR/../*.rs $SCRIPT_DIR/../runtime/src/weights/
  20. echo "Weights generated successfully for $1"
  21. echo "It took $((end-start)) seconds"
  22. else
  23. >&2 echo "$ERROR"
  24. >&2 echo "There was a problem generating the weights for $1, check the error above"
  25. exit 1
  26. fi
  27. }
  28. # Joystream benchmarks
  29. benchmark storage_v2