mirror of https://github.com/nextcloud/server.git
parent
fc6e07705a
commit
dd938dadef
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
export KB=1000
|
||||
export MB=$((KB*1000))
|
||||
|
||||
MAX_UPLOAD_SIZE=$((512*KB))
|
||||
|
||||
export CONCURRENCY=5
|
||||
export BANDWIDTH=$((100*MB/CONCURRENCY))
|
||||
|
||||
FILE_SIZES=($((1*KB)) $((10*KB)) $((100*KB)))
|
||||
|
||||
echo "Concurrency: $CONCURRENCY"
|
||||
echo "Bandwidth: $BANDWIDTH"
|
||||
|
||||
md_output="# Bulk upload benchmark\n"
|
||||
md_output+="\n"
|
||||
md_output+="- Concurrency: $CONCURRENCY\n"
|
||||
md_output+="- Bandwidth: ${BANDWIDTH}B\n"
|
||||
md_output+="\n"
|
||||
md_output+="| Nb | Size (B) | Bundle (sec) | Single (sec) |\n"
|
||||
md_output+="|---|---|---|---|\n"
|
||||
|
||||
requests_count='1 2 3 4 5'
|
||||
|
||||
for size in "${FILE_SIZES[@]}"
|
||||
do
|
||||
nb=$((MAX_UPLOAD_SIZE/size))
|
||||
|
||||
echo "- Upload of $nb tiny file of ${size}B"
|
||||
echo " - Bundled"
|
||||
start=$(date +%s)
|
||||
echo "$requests_count" | xargs -d ' ' -P $CONCURRENCY -I{} ./bundle_upload.sh "$nb" "$size"
|
||||
end=$(date +%s)
|
||||
bundle_exec_time=$((end-start))
|
||||
echo "${bundle_exec_time}s"
|
||||
|
||||
echo " - Single"
|
||||
start=$(date +%s)
|
||||
echo "$requests_count" | xargs -d ' ' -P $CONCURRENCY -I{} ./single_upload.sh "$nb" "$size"
|
||||
end=$(date +%s)
|
||||
single_exec_time=$((end-start))
|
||||
echo "${single_exec_time}s"
|
||||
|
||||
md_output+="| $nb | $size | $bundle_exec_time | $single_exec_time |\n"
|
||||
done
|
||||
|
||||
echo -en "$md_output"
|
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
KB=${KB:-100}
|
||||
MB=${MB:-$((KB*1000))}
|
||||
|
||||
NB=$1
|
||||
SIZE=$2
|
||||
|
||||
CONCURRENCY=${CONCURRENCY:-1}
|
||||
BANDWIDTH=${BANDWIDTH:-$((100*MB/CONCURRENCY))}
|
||||
|
||||
USER="admin"
|
||||
PASS="password"
|
||||
SERVER="nextcloud.test"
|
||||
UPLOAD_PATH="/tmp/bundle_upload_request_$(openssl rand --hex 8).txt"
|
||||
BOUNDARY="boundary_$(openssl rand --hex 8)"
|
||||
LOCAL_FOLDER="/tmp/bundle_upload/${BOUNDARY}_${NB}_${SIZE}"
|
||||
REMOTE_FOLDER="/bundle_upload/${BOUNDARY}_${NB}_${SIZE}"
|
||||
|
||||
mkdir --parent "$LOCAL_FOLDER"
|
||||
|
||||
for ((i=1; i<="$NB"; i++))
|
||||
do
|
||||
file_name=$(openssl rand --hex 8)
|
||||
file_local_path="$LOCAL_FOLDER/$file_name.txt"
|
||||
file_remote_path="$REMOTE_FOLDER/$file_name.txt"
|
||||
head -c "$SIZE" /dev/urandom > "$file_local_path"
|
||||
file_mtime=$(stat -c %Y "$file_local_path")
|
||||
file_hash=$(md5sum "$file_local_path" | awk '{ print $1 }')
|
||||
file_size=$(du -sb "$file_local_path" | awk '{ print $1 }')
|
||||
|
||||
{
|
||||
echo -en "--$BOUNDARY\r\n"
|
||||
# echo -en "Content-ID: $file_name\r\n"
|
||||
echo -en "X-File-Path: $file_remote_path\r\n"
|
||||
echo -en "X-File-Mtime: $file_mtime\r\n"
|
||||
# echo -en "X-File-Id: $file_id\r\n"
|
||||
echo -en "X-File-Md5: $file_hash\r\n"
|
||||
echo -en "Content-Length: $file_size\r\n"
|
||||
echo -en "\r\n" >> "$UPLOAD_PATH"
|
||||
|
||||
cat "$file_local_path"
|
||||
echo -en "\r\n" >> "$UPLOAD_PATH"
|
||||
} >> "$UPLOAD_PATH"
|
||||
done
|
||||
|
||||
echo -en "--$BOUNDARY--\r\n" >> "$UPLOAD_PATH"
|
||||
|
||||
echo "Creating folder /${BOUNDARY}_${NB}_${SIZE}"
|
||||
curl \
|
||||
-X MKCOL \
|
||||
-k \
|
||||
"https://$USER:$PASS@$SERVER/remote.php/dav/files/$USER/$REMOTE_FOLDER"
|
||||
|
||||
echo "Uploading $NB files with total size: $(du -sh "$UPLOAD_PATH" | cut -d ' ' -f1)"
|
||||
echo "Local file is: $UPLOAD_PATH"
|
||||
blackfire curl \
|
||||
-X POST \
|
||||
-k \
|
||||
--progress-bar \
|
||||
--limit-rate "${BANDWIDTH}k" \
|
||||
--cookie "XDEBUG_PROFILE=MROW4A;path=/;" \
|
||||
-H "Content-Type: multipart/related; boundary=$BOUNDARY" \
|
||||
--data-binary "@$UPLOAD_PATH" \
|
||||
"https://$USER:$PASS@$SERVER/remote.php/dav/files/bundle"
|
||||
|
||||
rm -rf "${LOCAL_FOLDER:?}"
|
||||
rm "$UPLOAD_PATH"
|
@ -1,149 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
user='admin'
|
||||
pass='admin'
|
||||
server='localhost/owncloud'
|
||||
upload="/tmp/upload.txt"
|
||||
|
||||
|
||||
testfile2="$script_path/zombie.jpg"
|
||||
size2=$(du -sb $testfile2 | awk '{ print $1 }')
|
||||
md52=$(md5sum $testfile2 | awk '{ print $1 }')
|
||||
|
||||
header="<?xml version='1.0' encoding='UTF-8'?>\n
|
||||
<d:multipart xmlns:d=\"DAV:\">\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie1.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>0</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie2.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>1</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie3.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>2</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie4.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>3</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie5.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>4</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie6.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>5</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie7.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>6</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie8.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>7</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie9.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>8</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/test/zombie10.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>9</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
</d:multipart>"
|
||||
headersize=$(echo -en $header | wc -c)
|
||||
|
||||
mdupload=$(md5sum $upload | awk '{ print $1 }')
|
||||
boundrary="boundary_$mdupload"
|
||||
|
||||
#CONTENTS
|
||||
echo -en "--$boundrary\r\nContent-Type: text/xml; charset=utf-8\r\nContent-Length: $headersize\r\n\r\n" > $upload
|
||||
echo -en $header >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 0\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 1\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 2\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 3\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 4\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 5\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 6\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 7\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 8\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
echo -en "\r\n--$boundrary\r\nContent-ID: 9\r\n\r\n" >> $upload
|
||||
cat $testfile2 >> $upload
|
||||
|
||||
#END BOUNDRARY
|
||||
echo -en "\r\n--$boundrary--\r\n" >> $upload
|
||||
|
||||
#POST
|
||||
#curl -X DELETE -u $user:$pass --cookie "XDEBUG_SESSION=MROW4A;path=/;" "http://$server/remote.php/webdav/config.cfg"
|
||||
|
||||
blackfire --samples 1 curl -X POST -H "Content-Type: multipart/related; boundary=$boundrary" --cookie "XDEBUG_SESSION=MROW4A;path=/;" \
|
||||
--data-binary "@$upload" \
|
||||
"http://$user:$pass@$server/remote.php/dav/files/$user"
|
||||
|
||||
|
||||
|
||||
|
@ -1,70 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
scriptPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
user='admin'
|
||||
pass='password'
|
||||
server='nextcloud.test'
|
||||
upload="/tmp/upload.txt"
|
||||
|
||||
|
||||
testFile1="$scriptPath/put_test.sh"
|
||||
size1=$(du -sb "$testFile1" | awk '{ print $1 }')
|
||||
# md51=$(md5sum "$testFile1" | awk '{ print $1 }')
|
||||
id1="0"
|
||||
|
||||
testFile2="$scriptPath/screenshot.png"
|
||||
size2=$(du -sb "$testFile2" | awk '{ print $1 }')
|
||||
# md52=$(md5sum "$testFile2" | awk '{ print $1 }')
|
||||
id2="1"
|
||||
|
||||
header="<?xml version='1.0' encoding='UTF-8'?>\n
|
||||
<d:multipart xmlns:d=\"DAV:\">\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/put_test.sh</d:oc-path>\n
|
||||
<d:oc-mtime>1476393777</d:oc-mtime>\n
|
||||
<d:oc-id>$id1</d:oc-id>\n
|
||||
<d:oc-total-length>$size1</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
<d:part>\n
|
||||
<d:prop>\n
|
||||
<d:oc-path>/zombie.jpg</d:oc-path>\n
|
||||
<d:oc-mtime>1476393386</d:oc-mtime>\n
|
||||
<d:oc-id>$id2</d:oc-id>\n
|
||||
<d:oc-total-length>$size2</d:oc-total-length>\n
|
||||
</d:prop>\n
|
||||
</d:part>\n
|
||||
</d:multipart>"
|
||||
headerSize=$(echo -en "$header" | wc -c)
|
||||
|
||||
mdUpload=$(md5sum $upload | awk '{ print $1 }')
|
||||
boundary="boundary_$mdUpload"
|
||||
|
||||
#CONTENTS
|
||||
echo -en "--$boundary\r\nContent-Type: text/xml; charset=utf-8\r\nContent-Length: $headerSize\r\n\r\n" > $upload
|
||||
echo -en "$header" >> $upload
|
||||
|
||||
cat "$upload"
|
||||
echo -en "\r\n--$boundary\r\nContent-ID: $id1\r\n\r\n" >> $upload
|
||||
cat "$testFile1" >> $upload
|
||||
|
||||
echo -en "\r\n--$boundary\r\nContent-ID: $id2\r\n\r\n" >> $upload
|
||||
cat "$testFile2" >> $upload
|
||||
|
||||
#END boundary
|
||||
echo -en "\r\n--$boundary--\r\n" >> $upload
|
||||
|
||||
#POST
|
||||
#curl -X DELETE -u $user:$pass --cookie "XDEBUG_SESSION=MROW4A;path=/;" "http://$server/remote.php/webdav/config.cfg"
|
||||
|
||||
curl -X POST -k -H "Content-Type: multipart/related; boundary=$boundary" --cookie "XDEBUG_SESSION=MROW4A;path=/;" \
|
||||
--data-binary "@$upload" \
|
||||
"https://$user:$pass@$server/remote.php/dav/files/bundle"
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
user='admin'
|
||||
pass='admin'
|
||||
server='localhost/owncloud'
|
||||
|
||||
testfile2="$script_path/zombie.jpg"
|
||||
|
||||
blackfire --samples 1 curl -X PUT -u $user:$pass --cookie "XDEBUG_SESSION=MROW4A;path=/;" --data-binary @"$testfile2" "http://$server/remote.php/webdav/test/zombie.jpg"
|
||||
#curl -X PUT -u $user:$pass --cookie "XDEBUG_SESSION=MROW4A;path=/;" --data-binary @"$testfile2" "http://$server/remote.php/webdav/test/zombie.jpg"
|
Binary file not shown.
Before Width: | Height: | Size: 179 KiB |
@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
export KB=${KB:-100}
|
||||
export MB=${MB:-$((KB*1000))}
|
||||
|
||||
export NB=$1
|
||||
export SIZE=$2
|
||||
|
||||
export CONCURRENCY=${CONCURRENCY:-1}
|
||||
export BANDWIDTH=${BANDWIDTH:-$((100*MB/CONCURRENCY))}
|
||||
|
||||
export USER="admin"
|
||||
export PASS="password"
|
||||
export SERVER="nextcloud.test"
|
||||
export UPLOAD_ID="single_$(openssl rand --hex 8)"
|
||||
export LOCAL_FOLDER="/tmp/bundle_upload/${UPLOAD_ID}_${NB}_${SIZE}"
|
||||
export REMOTE_FOLDER="/bundle_upload/${UPLOAD_ID}_${NB}_${SIZE}"
|
||||
|
||||
mkdir --parent "$LOCAL_FOLDER"
|
||||
|
||||
curl \
|
||||
-X MKCOL \
|
||||
-k \
|
||||
--cookie "XDEBUG_SESSION=MROW4A;path=/;" \
|
||||
"https://$USER:$PASS@$SERVER/remote.php/dav/files/$USER/$REMOTE_FOLDER"
|
||||
|
||||
upload_file() {
|
||||
file_name=$(openssl rand --hex 8)
|
||||
file_local_path="$LOCAL_FOLDER/$file_name.txt"
|
||||
file_remote_path="$REMOTE_FOLDER/$file_name.txt"
|
||||
head -c "$SIZE" /dev/urandom > "$file_local_path"
|
||||
|
||||
curl \
|
||||
-X PUT \
|
||||
-k \
|
||||
--limit-rate "${BANDWIDTH}k" \
|
||||
--data-binary @"$file_local_path" "https://$USER:$PASS@$SERVER/remote.php/webdav/$file_remote_path"
|
||||
}
|
||||
export -f upload_file
|
||||
|
||||
file_list=''
|
||||
for ((i=1; i<"$NB"; i++))
|
||||
do
|
||||
file_list+="$i "
|
||||
done
|
||||
file_list+=$NB
|
||||
|
||||
echo "$file_list" | xargs -d ' ' -P "$((CONCURRENCY/5))" -I{} bash -c "upload_file {}"
|
||||
|
||||
printf "\n"
|
||||
|
||||
rm -rf "${LOCAL_FOLDER:?}"/*
|
Loading…
Reference in New Issue