xref: /aosp_15_r20/external/aws-sdk-java-v2/test/s3-benchmarks/.scripts/benchmark (revision 8a52c7834d808308836a99fc2a6e0ed8db339086)
1#!/bin/bash
2
3#
4# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License").
7# You may not use this file except in compliance with the License.
8# A copy of the License is located at
9#
10#  http://aws.amazon.com/apache2.0
11#
12# or in the "license" file accompanying this file. This file is distributed
13# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14# express or implied. See the License for the specific language governing
15# permissions and limitations under the License.
16#
17
18# Script for running multiple Transfer manager benchmarks at the same time
19
20usage() {
21  echo "usage:"
22  echo "    benchmark download|upload fs|tmpfs|no-op [<size>]"
23  echo "example:"
24  echo "    ./benchmark download fs"
25  echo "    ./benchmark upload tmpfs"
26  echo "    ./benchmark download fs 90GB"
27}
28
29# validate operation
30if [[ -z "$1" ]]; then
31  usage
32  exit 1
33fi
34
35operation="$1"
36
37if ([ "$operation" != download ] && [ "$operation" != upload ] && [ "$operation" != copy ]); then
38  usage
39  exit 1
40fi
41
42#validate location
43if [[ -z "$2" ]]; then
44  usage
45  exit 1
46fi
47
48location_name="$2"
49if ([ "$location_name" != fs ] && [ "$location_name" != tmpfs ] && [ "$location_name" != "no-op" ]); then
50  usage
51  exit 1
52fi
53
54if [ "$location_name" == fs ]; then
55  location="/"
56fi
57
58if [ "$location_name" == tmpfs ]; then
59  location="/dev/shm/"
60fi
61
62if [ ! -d result ]; then
63  mkdir result
64fi
65
66sizes_str="1B 8MB+1 8MB-1 128MB 4GB 30GB"
67versions_str="v1 v2 CRT java"
68sizes=( $sizes_str )
69versions=( $versions_str )
70
71echo "===== TM PERF TEST SUITE - $operation - $location_name ====="
72
73run_benchmark() {
74  echo "Benchmark: $version - $size"
75  result_file="$operation"_"$location_name"_"$version"_"$size".txt
76  cmd="java -jar ../target/s3-benchmarks.jar \
77            --key=$size \
78            --operation=$operation \
79            --bucket=do-not-delete-crt-s3-eu-west-1 \
80            --partSizeInMB=8 \
81            --maxThroughput=100.0 \
82            --iteration=8 \
83            --version=$version \
84            --readBufferInMB=3072"
85  if [[ -n $location ]]
86  then
87    cmd="$cmd --file=$location$size"
88  fi
89
90  echo "$cmd" | sed 's/ \{1,\}/ /g' > "result/$result_file"
91  $cmd | tee -a "result/$result_file"
92  echo "Benchmark done"
93}
94
95for (( i = 0; i < "${#versions[@]}"; i++ ))
96do
97  version="${versions[$i]}"
98  if [ ! -z "$3" ]
99  then
100    size="$3"
101    run_benchmark
102  else
103    for (( j = 0; j < "${#sizes[@]}"; j++ ))
104    do
105      size="${sizes[$j]}"
106      run_benchmark
107    done
108  fi
109done
110