git_update/performance_tests.sh

199 lines
6.2 KiB
Bash
Raw Normal View History

#!/bin/bash
. driglibash-base
2024-07-03 12:51:49 +00:00
. creation_repo.sh &> /dev/null
2024-06-27 17:26:06 +00:00
#prerequisite: creation_repo.sh has been run
2024-07-02 16:00:35 +00:00
FILES_TO_KEEP='sample0'
2024-07-03 12:51:49 +00:00
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
-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 "
}
2024-07-02 16:00:35 +00:00
#TESTS ON THE INITIAL CLONING
test0(){
section TEST0
echo "TEST 0 : case of classic cloning."
2024-07-03 12:51:49 +00:00
git clone --progress --no-local $1 2> cloning_text
2024-07-02 16:00:35 +00:00
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"
2024-07-03 12:51:49 +00:00
run rm cloning_text
2024-07-02 16:00:35 +00:00
run rm -rf $REPO_NAME
}
test1(){
section TEST1
echo "TEST 1 : case of --single-branch cloning."
2024-07-03 12:51:49 +00:00
git clone --progress --single-branch --no-local $1 2> cloning_text
2024-07-02 16:00:35 +00:00
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"
2024-07-03 12:51:49 +00:00
run rm cloning_text
run rm -rf $REPO_NAME
2024-06-28 16:29:11 +00:00
}
test2(){
section TEST2
echo "TEST 2 : case of --depth=1 --no-single-branch"
2024-07-03 12:51:49 +00:00
git clone --progress --depth=1 --no-local --no-single-branch $1 2> cloning_text
2024-07-02 16:00:35 +00:00
mem2=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
2024-06-28 16:29:11 +00:00
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"
2024-07-03 12:51:49 +00:00
run rm cloning_text
run rm -rf $REPO_NAME
2024-06-28 16:29:11 +00:00
}
test3(){
section TEST3
echo "TEST 3 : case of --depth=1 with single-branch (default))"
2024-07-03 12:51:49 +00:00
git clone --progress --single-branch --no-local --depth=1 $1 2> cloning_text
2024-07-02 16:00:35 +00:00
mem3=$(du ./$REPO_NAME| tail -n1 | tr -cd [:digit:])
2024-06-28 16:29:11 +00:00
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"
2024-07-03 12:51:49 +00:00
run rm cloning_text
run rm -rf $REPO_NAME
}
2024-07-01 15:57:28 +00:00
test4(){
section TEST4
2024-07-02 16:00:35 +00:00
run mkdir $REPO_NAME
2024-07-01 15:57:28 +00:00
run echo 'TEST 4 : case of sparse-checking only some files with depth=1'
2024-07-02 16:00:35 +00:00
run cd $REPO_NAME
2024-07-01 15:57:28 +00:00
run git init -q
run git config core.sparsecheckout true
2024-07-02 16:00:35 +00:00
run echo $FILES_TO_KEEP >> .git/info/sparse-checkout
2024-07-03 12:51:49 +00:00
run git remote add -f origin file://$1 #&> /dev/null
run git pull origin main #&> /dev/null
2024-07-01 15:57:28 +00:00
mem4=$(du . | tail -n1 | tr -cd [:digit:])
2024-07-02 16:00:35 +00:00
echo "memory usage with sparse checking only $FILES_TO_KEEP : $mem4"
echo "The bandwidth usage is not available through the Git commands."
2024-07-03 12:51:49 +00:00
run rm cloning_text
2024-07-02 16:00:35 +00:00
run rm -rf $REPO_NAME
}
#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'
2024-07-02 16:00:35 +00:00
run git clone $1 &> /dev/null
cd $REPO_NAME
2024-07-03 14:55:26 +00:00
run git fetch --progress origin &> /dev/null
run git merge --progress origin &> /dev/null
2024-07-03 12:51:49 +00:00
mem5before=$(du . | tail -n1 | tr -cd [:digit:])
#modification of the remote repo
2024-07-03 14:55:26 +00:00
cd ../$REMOTE
run dd if=/dev/urandom of=sample5 bs=1M count=1 &> /dev/null #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
2024-07-03 12:51:49 +00:00
mem5after=$(du . | tail -n1 | tr -cd [:digit:])
mem5=$(($mem5after-$mem5before))
bw5=$(grep -e "\->" merging_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
2024-07-02 16:00:35 +00:00
echo "memory usage in a classic fetching and merging : $mem5"
2024-07-03 14:55:26 +00:00
echo "bandwidth usage : $bw5"
cd ../$REMOTE
git reset --hard -q a99be63309fc4f4600210000583546d966d12d4f
cd ../..
rm -rf performance_testing
2024-07-01 15:57:28 +00:00
}
2024-07-02 16:00:35 +00:00
test6(){
section TEST5
run echo 'TEST 6 : case of classic fetching and merging, after removal of a 1M file'
run git clone $1 &> /dev/null
cd $REPO_NAME
run git fetch --progress origin &> /dev/null
run git merge --progress origin &> /dev/null
mem6before=$(du . | tail -n1 | tr -cd [:digit:])
#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
run git fetch --progress origin &> fetching_text
run git merge --progress &> merging_text
mem6after=$(du . | tail -n1 | tr -cd [:digit:])
mem6=$(($mem6after-$mem6before))
bw6=$(grep -e "\->" merging_text| grep -o "[[:digit:].]* -> [[:digit:].]* [[:alpha:]]*")
echo "memory usage in a classic fetching and merging : $mem6"
echo "bandwidth usage : $bw6"
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
2024-07-01 15:57:28 +00:00
while getopts ":hn:a" option; do
case $option in
h) # display Help
Help
exit;;
n)
TEST_NUM=$OPTARG;;
a)
ALL_TESTS=true;;
2024-07-03 12:51:49 +00:00
\?) # Invalid option
echo "Error: Invalid option here"
exit;;
esac
done
if [ "$ALL_TESTS" = true ]; then
2024-07-03 12:51:49 +00:00
test0 $REMOTE
test1 $REMOTE
test2 $REMOTE
test3 $REMOTE
test4 $REMOTE
test5 $REMOTE
test6 $REMOTE
2024-06-28 16:29:11 +00:00
elif [ -n "$TEST_NUM" ]; then
case $TEST_NUM in
0)
2024-07-03 12:51:49 +00:00
test0 $REMOTE;;
1)
2024-07-03 12:51:49 +00:00
test1 $REMOTE;;
2024-06-28 16:29:11 +00:00
2)
2024-07-03 12:51:49 +00:00
test2 $REMOTE;;
2024-06-28 16:29:11 +00:00
3)
2024-07-03 12:51:49 +00:00
test3 $REMOTE;;
2024-07-01 15:57:28 +00:00
4)
2024-07-03 12:51:49 +00:00
test4 $REMOTE;;
2024-07-02 16:00:35 +00:00
5)
2024-07-03 12:51:49 +00:00
test5 $REMOTE;;
6)
test6 $REMOTE;;
*)
echo "Error: Invalid test number"
die;;
esac
else
Help
fi
2024-07-02 16:00:35 +00:00
#optimize in case all tests are run
2024-07-03 14:55:26 +00:00
#adapt in case of different units