debut tests fetch

This commit is contained in:
eleonore12345 2024-07-02 18:00:35 +02:00
parent 17258b1cd1
commit 5241d2168b

View File

@ -2,7 +2,8 @@
. driglibash-base
#prerequisite: creation_repo.sh has been run
files_to_keep='sample0'
FILES_TO_KEEP='sample0'
REPO_NAME='performance_testing'
Help()
{
echo "
@ -19,72 +20,93 @@ DESCRIPTION
TEST1: --single-branch "
}
#TESTS ON THE INITIAL CLONING
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:])
mem0=$(du ./$REPO_NAME | 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
run rm -rf $REPO_NAME
}
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:])
mem1=$(du ./$REPO_NAME| 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
rm -rf $REPO_NAME
}
test2(){
section TEST2
echo "TEST 2 : case of --depth=1 --no-single-branch"
git clone --progress --depth=1 --no-single-branch $1 2> cloning_text
mem2=$(du ./performance_testing | tail -n1 | tr -cd [:digit:])
mem2=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
bw2=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
echo "memory usage in a --depth=1 --no-single-branch cloning : $mem2"
echo "bandwidth usage : $bw2"
run
rm -rf performance_testing
rm -rf $REPO_NAME
}
test3(){
section TEST3
echo "TEST 3 : case of --depth=1 with single-branch (default))"
git clone --progress --single-branch --depth=1 $1 2> cloning_text
mem3=$(du ./performance_testing | tail -n1 | tr -cd [:digit:])
mem3=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
bw3=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
echo "memory usage in a --depth=1 with single-branch cloning : $mem3"
echo "bandwidth usage : $bw3"
run
rm -rf performance_testing
rm -rf $REPO_NAME
}
test4(){
section TEST4
run mkdir $REPO_NAME
run echo 'TEST 4 : case of sparse-checking only some files with depth=1'
run mkdir performance_testing #to do : isoler le nom de l'URL
run cd performance_testing
run cd $REPO_NAME
run git init -q
run git config core.sparsecheckout true
run echo $files_to_keep >> .git/info/sparse-checkout
run git remote add -f origin $1 &> cloning_text #to do : find a way to do this quietly/why isn't it writing in cloning_text?
echo 'juste avant le pull'
run git pull --progress origin main 2> cloning_text #to do : adapter au cas où ce soit master et pas main
run echo $FILES_TO_KEEP >> .git/info/sparse-checkout
run git remote add -f origin $1 &> /dev/null
run git pull origin main &> /dev/null
mem4=$(du . | tail -n1 | tr -cd [:digit:])
bw4=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
echo "memory usage in a --depth=1 with sparse checking only $files_to_keep : $mem4"
echo "bandwidth usage : $bw4"
echo "memory usage with sparse checking only $FILES_TO_KEEP : $mem4"
echo "The bandwidth usage is not available through the Git commands."
cd ..
run rm -rf performance_testing
run rm -rf $REPO_NAME
}
#est-ce que ça fait depth=1 ?
#TESTS ON THE UPDATING OF THE REPOSITORY
#WITHOUT CHANGING ANYTHING
test5(){
section TEST5
run echo 'TEST 5 : case of classic fetching and merging'
run git clone $1 &> /dev/null
cd $REPO_NAME
mem5temp=$(du . | tail -n1 | tr -cd [:digit:])
run git fetch -v origin &> fetching_text
run git merge -v &> merging_text
mem5=$(du . | tail -n1 | tr -cd [:digit:])
echo "memory usage in a classic fetching and merging : $mem5"
echo "bandwidth usage : $bw5"
}
#test 6 : shallow exclude
while getopts ":hn:a" option; do
case $option in
@ -116,6 +138,7 @@ if [ "$ALL_TESTS" = true ]; then
test2 $REPO_LINK
test3 $REPO_LINK
test4 $REPO_LINK
test5 $REPO_LINK
elif [ -n "$TEST_NUM" ]; then
case $TEST_NUM in
@ -129,6 +152,8 @@ elif [ -n "$TEST_NUM" ]; then
test3 $REPO_LINK;;
4)
test4 $REPO_LINK;;
5)
test5 $REPO_LINK;;
*)
echo "Error: Invalid test number"
die;;
@ -137,5 +162,5 @@ else
Help
fi
#to do : use a local remote
#optimize in case all tests are run