457 lines
14 KiB
Bash
Executable File
457 lines
14 KiB
Bash
Executable File
#!/bin/bash
|
|
. creation_repo.sh &> /dev/null
|
|
|
|
FILES_TO_KEEP='sample0'
|
|
REMOTE="./remote/performance_testing"
|
|
|
|
Help()
|
|
{
|
|
echo "
|
|
NAME
|
|
performance_tests.sh
|
|
SYNOPSIS
|
|
performance_tests.sh [-a] [-h] [-n number]
|
|
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. 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 cloning
|
|
TEST2: --depth=1 --no-single-branch cloning
|
|
TEST3: --depth=1 cloning
|
|
TEST4: sparse-checking 1M sample0 only cloning
|
|
_________________
|
|
TEST5: classic fetching and merging after addition of a 1M file
|
|
TEST6: classic fetching and merging, after removal of a 1M file
|
|
TEST7: classic fetching and merging, after addition then removal of a 1M file
|
|
TEST8: --depth=1 fetching and merging, after addition of a 1M file
|
|
TEST9: --depth=1 fetching and merging, after removal of a 1M file
|
|
TEST10: --depth=1 fetching and merging, after addition then removal of 1M a file"
|
|
}
|
|
|
|
#USEFUL FUNCTIONS FOR THE TESTS
|
|
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:]]*")
|
|
fi
|
|
}
|
|
|
|
#TESTS ON THE INITIAL POPULATING OF THE REPO
|
|
test0(){
|
|
section TEST0
|
|
echo "TEST 0 : case of classic cloning."
|
|
git clone --recurse-submodules --progress --no-local $1 2> cloning_text
|
|
get_storage_used "./$REPO_NAME"
|
|
get_bandwidth cloning_text
|
|
echo "memory usage in a classic cloning : $mem"
|
|
echo "bandwidth usage : $bw"
|
|
run rm cloning_text
|
|
#run rm -rf $REPO_NAME
|
|
}
|
|
|
|
test1(){
|
|
section TEST1
|
|
echo "TEST 1 : case of --single-branch cloning."
|
|
git clone --recurse-submodules --progress --single-branch --no-local $1 2> cloning_text
|
|
get_storage_used ./$REPO_NAME
|
|
get_bandwidth cloning_text
|
|
echo "memory usage in a --single-branch cloning : $mem"
|
|
echo "bandwidth usage : $bw"
|
|
run rm cloning_text
|
|
run rm -rf $REPO_NAME
|
|
}
|
|
|
|
test2(){
|
|
section TEST2
|
|
echo "TEST 2 : case of --depth=1 --no-single-branch"
|
|
git clone --recurse-submodules --progress --depth=1 --no-local --no-single-branch $1 2> cloning_text
|
|
get_storage_used ./$REPO_NAME
|
|
get_bandwidth cloning_text
|
|
echo "memory usage in a --depth=1 --no-single-branch cloning : $mem"
|
|
echo "bandwidth usage : $bw"
|
|
run rm cloning_text
|
|
run rm -rf $REPO_NAME
|
|
}
|
|
|
|
test3(){
|
|
section TEST3
|
|
echo "TEST 3 : case of --depth=1 with single-branch (default))"
|
|
git clone --recurse-submodules --recurse-submodules --progress --single-branch --no-local --depth=1 $1 2> cloning_text
|
|
get_storage_used ./$REPO_NAME
|
|
get_bandwidth cloning_text
|
|
echo "memory usage in a --depth=1 with single-branch cloning : $mem"
|
|
echo "bandwidth usage : $bw"
|
|
run rm cloning_text
|
|
#run rm -rf $REPO_NAME
|
|
}
|
|
|
|
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 .
|
|
echo "memory usage: $mem"
|
|
echo "bandwidth usage : unknown"
|
|
cd ..
|
|
#run rm -rf $REPO_NAME
|
|
}
|
|
|
|
|
|
#TESTS ON THE UPDATING OF THE REPOSITORY
|
|
test5(){
|
|
section TEST5
|
|
run echo 'TEST 5 : case of classic fetching and merging, after addition of a 1M file'
|
|
#initialization
|
|
run git clone --recurse-submodules $1 &> /dev/null
|
|
cd $REPO_NAME
|
|
#run git submodule update --init --recursive --force --recommend-shallow
|
|
run git fetch --progress 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
|
|
#fetching
|
|
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
#get_bandwidth fetching_text
|
|
echo "memory usage: +$mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~1
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
test6(){
|
|
section TEST6
|
|
run echo 'TEST 6 : case of classic fetching and merging, after removal of a 1M file'
|
|
#initialization
|
|
run git clone --recurse-submodules $1 #&> /dev/null
|
|
cd $REPO_NAME
|
|
get_storage_used .
|
|
mem_before=$mem
|
|
#modification of the remote repo
|
|
cd ../$REMOTE
|
|
run rm sample0
|
|
run git add sample0
|
|
run git commit --quiet -m"1M sample0 deleted"
|
|
cd ../../$REPO_NAME
|
|
#fetching
|
|
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: $mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~1
|
|
git clean -df
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
test7(){
|
|
section TEST7
|
|
run echo 'TEST 7 : case of classic fetching and merging, after addition then removal of a 1M file'
|
|
#initialization
|
|
run git clone --recurse-submodules $1 &> /dev/null
|
|
cd $REPO_NAME
|
|
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"
|
|
run rm sample5
|
|
run git add sample5
|
|
run git commit --quiet -m"1M "sample5" deleted"
|
|
cd ../../$REPO_NAME
|
|
#fetching
|
|
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: $mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~2
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
test8(){
|
|
section TEST8
|
|
run echo 'TEST 8 : case of fetching --depth=1 and merging, after addition of a 1M file'
|
|
#initialization
|
|
echo $(pwd)
|
|
run git clone --recurse-submodules $1 &> /dev/null
|
|
cd $REPO_NAME
|
|
echo "un truc écrit en plus" >> untexte
|
|
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 --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: +$mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~1
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
test9(){
|
|
section TEST9
|
|
run echo 'TEST 9 : case of --depth=1 fetching and merging, after removal of a 1M file'
|
|
#initialization
|
|
run git clone --recurse-submodules $1 &> /dev/null
|
|
cd $REPO_NAME
|
|
get_storage_used .
|
|
mem_before=$mem
|
|
#modification of the remote repo
|
|
cd ../$REMOTE
|
|
run rm sample0
|
|
run git add sample0
|
|
run git commit --quiet -m"1M sample0 deleted"
|
|
cd ../../$REPO_NAME
|
|
#fetching
|
|
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: $mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~1
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
test10(){
|
|
section TEST10
|
|
run echo 'TEST 10 : case of --depth=1 fetching and merging, after addition then removal of a 1M file'
|
|
run git clone --recurse-submodules $1 &> /dev/null
|
|
cd $REPO_NAME
|
|
get_storage_used .
|
|
mem_before=$mem
|
|
pwd
|
|
#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"
|
|
run rm sample5
|
|
run git add sample5
|
|
run git commit --quiet -m"1M "sample5" deleted"
|
|
cd ../../$REPO_NAME
|
|
#fetching
|
|
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: $mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~2
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
test11(){
|
|
section TEST11
|
|
run echo 'TEST 11 : case of --depth=1 fetching and merging, after addition of a 1M file in submodule'
|
|
pwd
|
|
run git clone --recurse-submodules $1
|
|
cd $REPO_NAME
|
|
get_storage_used .
|
|
mem_before=$mem
|
|
pwd
|
|
ls -la
|
|
#modification of the remote submodule
|
|
cd ../$REMOTE/$SUB_NAME
|
|
pwd
|
|
create_random_file 'sub_sample1' '1M'
|
|
git add sub_sample1
|
|
git commit --quiet -m"first 1M sample created"
|
|
cd ../../$REPO_NAME
|
|
#fetching
|
|
run git submodule update --init --recursive --force --recommend-shallow
|
|
run git fetch --progress --tags --depth=1 -recursive-submodules origin &> /dev/null
|
|
git checkout -f -recursive-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: $mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~2
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
test12(){
|
|
section TEST12
|
|
run echo 'TEST 12 : case of --depth=1 fetching and merging, after removal of a 1M file in submodule'
|
|
run git clone --recurse-submodules $1 &> /dev/null
|
|
cd $REPO_NAME
|
|
get_storage_used .
|
|
mem_before=$mem
|
|
pwd
|
|
#modification of the remote repo
|
|
cd ../$REMOTE/$SUB_NAME
|
|
ls -la
|
|
rm sub_sample1
|
|
git add sub_sample1
|
|
git commit -m"1M sub_sample1 deleted"
|
|
cd ../../$REPO_NAME
|
|
#fetching
|
|
run git submodule update --init --recursive --force --recommend-shallow
|
|
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: $mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~2
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
|
|
test13(){
|
|
section TEST13
|
|
run echo 'TEST 13 : case of --depth=1 fetching and merging, after addition then removal of a 1M file in submodule'
|
|
run git clone --recurse-submodules $1 &> /dev/null
|
|
cd $REPO_NAME
|
|
run git fetch --progress origin &> /dev/null
|
|
run git merge --progress origin &> /dev/null
|
|
get_storage_used .
|
|
mem_before=$mem
|
|
#modification of the remote repo
|
|
cd ../$REMOTE/$SUB_NAME
|
|
create_random_file 'sub_sample1' '5M'
|
|
git add sub_sample1
|
|
git commit -m"first 1M sample created"
|
|
rm sub_sample1
|
|
git add sub_sample1
|
|
git commit -m"1M sub_sample1 deleted"
|
|
cd ../../$REPO_NAME
|
|
#fetching
|
|
run git submodule update --init --recursive --force --recommend-shallow
|
|
run git fetch --progress --tags --depth=1 --recurse-submodules origin &> /dev/null
|
|
git checkout -f --recurse-submodules origin/main &> /dev/null
|
|
get_storage_used .
|
|
mem_after=$mem
|
|
mem=$(($mem_after-$mem_before))
|
|
echo "memory usage: $mem"
|
|
cd ../$REMOTE
|
|
git reset --hard -q HEAD~2
|
|
cd ../..
|
|
#rm -rf performance_testing
|
|
}
|
|
|
|
while getopts ":hn:a" option; do
|
|
case $option in
|
|
h) # display Help
|
|
Help
|
|
exit;;
|
|
n)
|
|
TEST_NUM=$OPTARG;;
|
|
a)
|
|
ALL_TESTS=true;;
|
|
\?) # Invalid option
|
|
echo "Error: Invalid option here"
|
|
exit;;
|
|
esac
|
|
done
|
|
|
|
if [ "$ALL_TESTS" = true ]; then
|
|
test0 $REMOTE
|
|
test1 $REMOTE
|
|
test2 $REMOTE
|
|
test3 $REMOTE
|
|
test4 $REMOTE
|
|
test5 $REMOTE
|
|
test6 $REMOTE
|
|
test7 $REMOTE
|
|
test8 $REMOTE
|
|
test9 $REMOTE
|
|
test10 $REMOTE
|
|
test11 $REMOTE
|
|
test12 $REMOTE
|
|
test13 $REMOTE
|
|
|
|
|
|
elif [ -n "$TEST_NUM" ]; then
|
|
case $TEST_NUM in
|
|
0)
|
|
test0 $REMOTE;;
|
|
1)
|
|
test1 $REMOTE;;
|
|
2)
|
|
test2 $REMOTE;;
|
|
3)
|
|
test3 $REMOTE;;
|
|
4)
|
|
test4 $REMOTE;;
|
|
5)
|
|
test5 $REMOTE;;
|
|
6)
|
|
test6 $REMOTE;;
|
|
7)
|
|
test7 $REMOTE;;
|
|
8)
|
|
test8 $REMOTE;;
|
|
9)
|
|
test9 $REMOTE;;
|
|
10)
|
|
test10 $REMOTE;;
|
|
11)
|
|
test11 $REMOTE;;
|
|
12)
|
|
test12 $REMOTE;;
|
|
13)
|
|
test13 $REMOTE;;
|
|
*)
|
|
echo "Error: Invalid test number"
|
|
die;;
|
|
esac
|
|
else
|
|
Help
|
|
fi
|
|
|
|
#optimize in case all tests are run
|
|
#adapt in case of different units |