From 4bc5aee98650102088ac4214fdc2dee0936fb6d2 Mon Sep 17 00:00:00 2001 From: emeric Date: Tue, 7 Nov 2023 23:20:47 +0100 Subject: [PATCH] Subsonic API: added a small utility to bench search3 endpoint --- src/tools/subsonic-api-bench/search3.sh | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 src/tools/subsonic-api-bench/search3.sh diff --git a/src/tools/subsonic-api-bench/search3.sh b/src/tools/subsonic-api-bench/search3.sh new file mode 100755 index 00000000..897b2a01 --- /dev/null +++ b/src/tools/subsonic-api-bench/search3.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +if [ "$#" -ne 6 ]; then + echo "Usage: $0 " + exit 1 +fi + +# make any command failure exit +set -e + +read -s -p "Enter password: " user_password +echo + +# Retrieve the argument from the command line +base_url="$1" +user="$2" +artist_count="$3" +album_count="$4" +song_count="$5" +batch_size="$6" + +start_time=$(date +%s.%3N) + +# artists +for ((i = 0; i < artist_count; i += $batch_size)); do + wget -q -O - "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=$batch_size&artistOffset=$i&albumCount=0&songCount=0" > /dev/null +done + +# albums +for ((i = 0; i < album_count; i += $batch_size)); do + wget -q -O - "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=0&albumCount=$batch_size&albumOffset=$i&songCount=0" > /dev/null +done + +# songs +for ((i = 0; i < song_count; i += $batch_size)); do + wget -q -O - "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=0&albumCount=0&songCount=$batch_size&songOffset=$i" > /dev/null +done + +end_time=$(date +%s.%3N) + +elapsed_time=$(echo "$end_time - $start_time" | bc) + +echo "Fetch time: $elapsed_time seconds" \ No newline at end of file