git_update/performance_tests.sh

89 lines
2.2 KiB
Bash
Raw Normal View History

#!/bin/bash
. driglibash-base
2024-06-27 17:26:06 +00:00
#prerequisite: creation_repo.sh has been run
#remove the local copy
Help()
{
echo "
NAME
performance_tests.sh
SYNOPSIS
performance_tests.sh [-h] [-a] [-n number] [SSH LINK to en empty remote git repository] OPTIONS
-a excutes all the tests.
-n [number] executes test [number]
-h prints the help.
DESCRIPTION
This script is in writing. It allows you to measure memory and bandwidth usage for different method of cloning on the remote repository given.
TEST0: classic cloning
TEST1: --single-branch "
}
test0(){
section TEST0
echo "TEST 0 : case of classic cloning."
git clone --progress $1 2> cloning_text
mem0=$(du ./performance_testing | tail -n1 | tr -cd [:digit:])
bw0=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
echo "memory usage in a classic cloning : $mem0"
echo "bandwidth usage : $bw0"
run rm -rf performance_testing
}
test1(){
section TEST1
echo "TEST 1 : case of --single-branch cloning."
git clone --progress --single-branch $1 2> cloning_text
mem1=$(du ./performance_testing | tail -n1 | tr -cd [:digit:])
bw1=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
echo "memory usage in a --single-branch cloning : $mem1"
echo "bandwidth usage : $bw1"
run
rm -rf performance_testing
}
while getopts ":hn:a" option; do
case $option in
h) # display Help
Help
exit;;
\?) # Invalid option
echo "Error: Invalid option"
exit;;
n)
TEST_NUM=$OPTARG;;
a)
ALL_TESTS=true;;
esac
done
shift "$(($OPTIND -1))" #so that the cloning link is in $1 no matter how many options were used
if [ -z "$1" ]; then
echo "Error: No repository link provided"
Help
die
else
REPO_LINK=$1
fi
if [ "$ALL_TESTS" = true ]; then
test0 $REPO_LINK
test1 $REPO_LINK
elif [ -n "$TEST_NUM" ]; then
case $TEST_NUM in
0)
test0 $REPO_LINK;;
1)
test1 $REPO_LINK;;
*)
echo "Error: Invalid test number"
die;;
esac
else
Help
fi
2024-06-27 17:31:53 +00:00