Compare commits

...

2 Commits

Author SHA1 Message Date
eleonore12345
b2178cfd6e bw débuggée 2024-07-04 16:42:39 +02:00
eleonore12345
b01eae167f bw dans une fonction séparée 2024-07-04 15:58:13 +02:00

View File

@ -34,18 +34,28 @@ get_storage_used(){
mem=$(du $1 | tail -n1 | tr -cd [:digit:])
}
get_bandwidth(){
bw="unknown"
if [ "$1" = "cloning_text" ]; then
bw=$(grep -e "Receiving objects:" $1 | grep -o "Receiving objects: [[:alnum:]%/(),. ]*" | tail -n1)
bw=${bw#*,}
elif [ "$1" = "fetching_text" ]; then
bw=$(grep -e "\->" fetching_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
echo "bw vaut $bw"
fi
}
#TESTS ON THE INITIAL CLONING
#TESTS ON THE INITIAL POPULATING OF THE REPO
test0(){
section TEST0
echo "TEST 0 : case of classic cloning."
git clone --progress --no-local $1 2> cloning_text
get_storage_used "./$REPO_NAME"
bw0=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
get_bandwidth cloning_text
echo "memory usage in a classic cloning : $mem"
echo "bandwidth usage : $bw0"
echo "bandwidth usage : $bw"
run rm cloning_text
run rm -rf $REPO_NAME
run rm -rf $REPO_NAME
}
test1(){
@ -53,9 +63,9 @@ test1(){
echo "TEST 1 : case of --single-branch cloning."
git clone --progress --single-branch --no-local $1 2> cloning_text
get_storage_used ./$REPO_NAME
bw1=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
get_bandwidth cloning_text
echo "memory usage in a --single-branch cloning : $mem"
echo "bandwidth usage : $bw1"
echo "bandwidth usage : $bw"
run rm cloning_text
run rm -rf $REPO_NAME
}
@ -65,9 +75,9 @@ test2(){
echo "TEST 2 : case of --depth=1 --no-single-branch"
git clone --progress --depth=1 --no-local --no-single-branch $1 2> cloning_text
get_storage_used ./$REPO_NAME
bw2=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
get_bandwidth cloning_text
echo "memory usage in a --depth=1 --no-single-branch cloning : $mem"
echo "bandwidth usage : $bw2"
echo "bandwidth usage : $bw"
run rm cloning_text
run rm -rf $REPO_NAME
}
@ -77,9 +87,9 @@ test3(){
echo "TEST 3 : case of --depth=1 with single-branch (default))"
git clone --progress --single-branch --no-local --depth=1 $1 2> cloning_text
get_storage_used ./$REPO_NAME
bw3=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
get_bandwidth cloning_text
echo "memory usage in a --depth=1 with single-branch cloning : $mem"
echo "bandwidth usage : $bw3"
echo "bandwidth usage : $bw"
run rm cloning_text
run rm -rf $REPO_NAME
}
@ -88,10 +98,12 @@ test4(){
section TEST4
run mkdir $REPO_NAME
run echo "TEST 4 : case of sparse-checking only $FILES_TO_KEEP with depth=1"
#creating a git repo with sparse-checking settings
run cd $REPO_NAME
run git init -q
run git config core.sparsecheckout true
run echo $FILES_TO_KEEP >> .git/info/sparse-checkout
#pulling from the remote with sparse-checking enabled
run git remote add -f origin ../$1 &> /dev/null
run git pull origin main &> /dev/null
get_storage_used .
@ -102,7 +114,6 @@ test4(){
}
#TESTS ON THE UPDATING OF THE REPOSITORY
#WITHOUT CHANGING ANYTHING
test5(){
section TEST5
run echo 'TEST 5 : case of classic fetching and merging, after addition of a 1M file'
@ -110,7 +121,7 @@ test5(){
cd $REPO_NAME
run git fetch --progress origin &> /dev/null
run git merge --progress origin &> /dev/null
get_storage_used .
get_storage_used .
mem_before=$mem
#modification of the remote repo
cd ../$REMOTE
@ -118,14 +129,14 @@ test5(){
run git add sample5
run git commit --quiet -m"fourth 1M sample created"
cd ../../$REPO_NAME
run git fetch --progress origin &> fetching_text
run git merge --progress &> merging_text
run git fetch --progress origin &> /dev/null
run git merge --progress &> fetching_text
get_storage_used .
mem_after=$mem
mem=$(($mem_after-$mem_before))
bw5=$(grep -e "\->" merging_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
get_bandwidth fetching_text
echo "memory usage: +$mem"
echo "bandwidth usage: $bw5"
echo "bandwidth usage: $bw"
cd ../$REMOTE
git reset --hard -q a99be63309fc4f4600210000583546d966d12d4f
cd ../..
@ -147,14 +158,14 @@ test6(){
run git add sample0
run git commit --quiet -m"1M sample0 deleted"
cd ../../$REPO_NAME
run git fetch --progress origin &> fetching_text
run git merge --progress &> merging_text
run git fetch --progress origin &> /dev/null
run git merge --progress &> fetching_text
get_storage_used .
mem_after=$mem
mem=$(($mem_after-$mem_before))
bw6=$(grep -e "\->" merging_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
get_bandwidth fetching_text
echo "memory usage: $mem"
echo "bandwidth usage: $bw6"
echo "bandwidth usage: $bw"
cd ../$REMOTE
git reset --hard -q a99be63309fc4f4600210000583546d966d12d4f
cd ../..
@ -162,7 +173,7 @@ test6(){
}
test7(){
section TEST7
section TEST7
run echo 'TEST 7 : case of classic fetching and merging, after addition then removal of a 1M file'
run git clone $1 &> /dev/null
cd $REPO_NAME
@ -179,8 +190,8 @@ test7(){
run git add sample5
run git commit --quiet -m"1M "sample5" deleted"
cd ../../$REPO_NAME
run git fetch --progress origin &> fetching_text
run git merge --progress &> merging_text
run git fetch --progress origin &> /dev/null
run git merge --progress &> /dev/null
get_storage_used .
mem_after=$mem
mem=$(($mem_after-$mem_before))
@ -192,9 +203,34 @@ test7(){
rm -rf performance_testing
}
#test 7 : --depth=1
#normalement supprime aussi l'historique
test8(){
section TEST8
run echo 'TEST 8 : case of classic fetching and merging, after addition of a 1M file'
run git clone $1 &> /dev/null
cd $REPO_NAME
run git fetch --progress --depth=1 origin &> /dev/null
run git merge --progress origin &> /dev/null
get_storage_used .
mem_before=$mem
#modification of the remote repo
cd ../$REMOTE
create_random_file 'sample5' '1M' #adding a 1M file
run git add sample5
run git commit --quiet -m"fourth 1M sample created"
cd ../../$REPO_NAME
run git fetch --progress origin &> /dev/null
run git merge --progress &> fetching_text
get_storage_used .
mem_after=$mem
mem=$(($mem_after-$mem_before))
get_bandwidth fetching_text
echo "memory usage: +$mem"
echo "bandwidth usage: $bw"
cd ../$REMOTE
git reset --hard -q a99be63309fc4f4600210000583546d966d12d4f
cd ../..
rm -rf performance_testing
}
@ -222,6 +258,7 @@ if [ "$ALL_TESTS" = true ]; then
test5 $REMOTE
test6 $REMOTE
test7 $REMOTE
test8 $REMOTE
elif [ -n "$TEST_NUM" ]; then
case $TEST_NUM in
@ -241,6 +278,8 @@ elif [ -n "$TEST_NUM" ]; then
test6 $REMOTE;;
7)
test7 $REMOTE;;
8)
test8 $REMOTE;;
*)
echo "Error: Invalid test number"
die;;