benchmark.sh 808 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. command -v php >/dev/null 2>&1 || { echo "I require `php` but it's not available. Aborting." >&2; exit 255; }
  3. command -v grep >/dev/null 2>&1 || { echo "I require `grep` but it's not available. Aborting." >&2; exit 255; }
  4. command -v awk >/dev/null 2>&1 || { echo "I require `awk` but it's not available. Aborting." >&2; exit 255; }
  5. if [ "" == "$1" ] || [ "" == "$2" ];
  6. then
  7. echo "Usage: bash benchmark.sh BRANCH1 BRANCH2 ...BRANCHN"
  8. exit 1;
  9. fi
  10. for BRANCH in $@
  11. do
  12. git checkout $BRANCH &> /dev/null &&
  13. git reset --hard &> /dev/null &&
  14. echo -n $BRANCH
  15. (for i in {1..10}; do php php-cs-fixer fix . ; done) | grep -i fixed | awk '
  16. {
  17. total += $5;
  18. ++count;
  19. }
  20. END {
  21. print " mean:" (total/count) " total:" total " rounds:" count
  22. }'
  23. done