storage and memory in separate functions

This commit is contained in:
eleonore12345 2024-07-04 11:01:04 +02:00
parent 912a969bdf
commit d4036f090e

View File

@ -2,33 +2,47 @@
. driglibash-base
. creation_repo.sh &> /dev/null
#prerequisite: creation_repo.sh has been run
FILES_TO_KEEP='sample0'
REMOTE="./remote/performance_testing"
Help()
{
echo "
NAME
performance_tests.sh
SYNOPSIS
performance_tests.sh [-h] [-a] [-n number] [SSH LINK to en empty remote git repository] OPTIONS
performance_tests.sh [-a] [-h] [-n number]
OPTIONS
-a excutes all the tests.
-n [number] executes test [number]
-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.
This script is in writing. It allows you to measure memory and bandwidth usage. The first four test different cloning methods. Te following apply changes to the local remote before testing fetching and merging commands.
TEST0: classic cloning
TEST1: --single-branch "
TEST1: --single-branch
TEST2: --depth=1 --no-single-branch
TEST3: --depth=1
TEST4: sparse-checking 1M sample0 only
_________________________________________
TEST5: classic fetching and merging after addition of 1M file
TEST6: "
}
#USEFUL FUNCTIONS FOR THE TESTS
get_storage_used(){
mem=$(du $1 | tail -n1 | tr -cd [:digit:])
}
#TESTS ON THE INITIAL CLONING
test0(){
section TEST0
echo "TEST 0 : case of classic cloning."
git clone --progress --no-local $1 2> cloning_text
mem0=$(du ./$REPO_NAME | tail -n1 | tr -cd [:digit:])
get_storage_used "./$REPO_NAME"
bw0=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
echo "memory usage in a classic cloning : $mem0"
echo "memory usage in a classic cloning : $mem"
echo "bandwidth usage : $bw0"
run rm cloning_text
run rm -rf $REPO_NAME
@ -38,9 +52,9 @@ test1(){
section TEST1
echo "TEST 1 : case of --single-branch cloning."
git clone --progress --single-branch --no-local $1 2> cloning_text
mem1=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
get_storage_used ./$REPO_NAME
bw1=$(grep -e "Receiving objects:" cloning_text| grep -o "[[:digit:].]* MiB " | tail -n1)
echo "memory usage in a --single-branch cloning : $mem1"
echo "memory usage in a --single-branch cloning : $mem"
echo "bandwidth usage : $bw1"
run rm cloning_text
run rm -rf $REPO_NAME
@ -50,9 +64,9 @@ test2(){
section 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
mem2=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
get_storage_used ./$REPO_NAME
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 "memory usage in a --depth=1 --no-single-branch cloning : $mem"
echo "bandwidth usage : $bw2"
run rm cloning_text
run rm -rf $REPO_NAME
@ -62,9 +76,9 @@ test3(){
section 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
mem3=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
get_storage_used ./$REPO_NAME
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 "memory usage in a --depth=1 with single-branch cloning : $mem"
echo "bandwidth usage : $bw3"
run rm cloning_text
run rm -rf $REPO_NAME
@ -78,12 +92,12 @@ test4(){
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 file://$1 #&> /dev/null
run git pull origin main #&> /dev/null
mem4=$(du . | tail -n1 | tr -cd [:digit:])
echo "memory usage: $mem4"
echo "The bandwidth usage is not available through the Git commands."
run rm cloning_text
run git remote add -f origin ../$1 &> /dev/null
run git pull origin main &> /dev/null
get_storage_used .
echo "memory usage: $mem"
echo "bandwidth usage unknown"
cd ..
run rm -rf $REPO_NAME
}
@ -96,19 +110,21 @@ test5(){
cd $REPO_NAME
run git fetch --progress origin &> /dev/null
run git merge --progress origin &> /dev/null
mem5before=$(du . | tail -n1 | tr -cd [:digit:])
get_storage_used .
mem_before=$mem
#modification of the remote repo
cd ../$REMOTE
run dd if=/dev/urandom of=sample5 bs=1M count=1 &> /dev/null #adding a 1M file
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 &> fetching_text
run git merge --progress &> merging_text
mem5after=$(du . | tail -n1 | tr -cd [:digit:])
mem5=$(($mem5after-$mem5before))
get_storage_used .
mem_after=$mem
mem=$(($mem_after-$mem_before))
bw5=$(grep -e "\->" merging_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
echo "memory usage: $mem5"
echo "memory usage: +$mem"
echo "bandwidth usage: $bw5"
cd ../$REMOTE
git reset --hard -q a99be63309fc4f4600210000583546d966d12d4f
@ -123,7 +139,8 @@ test6(){
cd $REPO_NAME
run git fetch --progress origin &> /dev/null
run git merge --progress origin &> /dev/null
mem6before=$(du . | tail -n1 | tr -cd [:digit:])
get_storage_used .
mem_before=$mem
#modification of the remote repo
cd ../$REMOTE
run rm sample0
@ -132,10 +149,11 @@ test6(){
cd ../../$REPO_NAME
run git fetch --progress origin &> fetching_text
run git merge --progress &> merging_text
mem6after=$(du . | tail -n1 | tr -cd [:digit:])
mem6=$(($mem6after-$mem6before))
get_storage_used .
mem_after=$mem
mem=$(($mem_after-$mem_before))
bw6=$(grep -e "\->" merging_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
echo "memory usage: $mem6"
echo "memory usage: $mem"
echo "bandwidth usage: $bw6"
cd ../$REMOTE
git reset --hard -q a99be63309fc4f4600210000583546d966d12d4f
@ -150,10 +168,11 @@ test7(){
cd $REPO_NAME
run git fetch --progress origin &> /dev/null
run git merge --progress origin &> /dev/null
mem7before=$(du . | tail -n1 | tr -cd [:digit:])
get_storage_used .
mem_before=$mem
#modification of the remote repo
cd ../$REMOTE
run dd if=/dev/urandom of=sample5 bs=1M count=1 &> /dev/null #adding a 1M file
create_random_file 'sample5' '1M' #adding a 1M file
run git add sample5
run git commit --quiet -m"fourth 1M sample created"
run rm sample5
@ -162,17 +181,17 @@ test7(){
cd ../../$REPO_NAME
run git fetch --progress origin &> fetching_text
run git merge --progress &> merging_text
mem7after=$(du . | tail -n1 | tr -cd [:digit:])
mem7=$(($mem7after-$mem7before))
bw7=$(grep -e "\->" merging_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
echo "memory usage: $mem7"
get_storage_used .
mem_after=$mem
mem=$(($mem_after-$mem_before))
echo "memory usage: $mem"
echo "bandwidth usage unknown"
cd ../$REMOTE
git reset --hard -q a99be63309fc4f4600210000583546d966d12d4f
cd ../..
rm -rf performance_testing
}
#modify to have a history of changes
#test 7 : --depth=1
#normalement supprime aussi l'historique