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-dir download|upload fs|tmpfs|no-op [1B|4K|16M|5G]" 23 echo "example:" 24 echo " ./benchmark-dir download fs" 25 echo " ./benchmark-dir upload tmpfs" 26 echo " ./benchmark download fs 5G" 27} 28 29# validate operation 30if [ -z "$1" ] || ([ "$1" != download ] && [ "$1" != upload ]); then 31 usage 32 exit 1 33fi 34operation="$1"_directory 35 36# validate location 37if [[ -z "$2" ]]; then 38 usage 39 exit 1 40fi 41 42location_name="$2" 43if ([ "$location_name" != fs ] && [ "$location_name" != tmpfs ] && [ "$location_name" != no-op ]); then 44 usage 45 exit 1 46fi 47 48if [[ "$location_name" == fs ]]; then 49 location="$HOME/tm_dir_files" 50fi 51 52if [[ "$location_name" == tmpfs ]]; then 53 location="/dev/shm/tm_dir_files" 54fi 55 56 57sizes_str="1B 4K 16M 5G" 58versions_str="v1 v2" 59sizes=( $sizes_str ) 60versions=( $versions_str ) 61 62run_benchmark() { 63 echo "Benchmark: $version - $size" 64 directory="$location/$size" 65 if [[ -z "$directory" ]]; then 66 mkdir -p "$directory" 67 fi 68 result_file="$operation"_"$location_name"_"$version"_"$size".txt 69 prefix="$size" 70 cmd="java -jar ../target/s3-benchmarks.jar \ 71 --operation=$operation \ 72 --bucket=do-not-delete-crt-s3-eu-west-1 \ 73 --partSizeInMB=8 \ 74 --maxThroughput=100.0 \ 75 --iteration=8 \ 76 --version=$version \ 77 --readBufferInMB=3072 \ 78 --prefix=$prefix \ 79 --file=$directory" 80 81 echo "$cmd" | sed 's/ \{1,\}/ /g' > "result/$result_file" 82 $cmd | tee -a "result/$result_file" 83 echo "Benchmark done" 84} 85 86for (( i = 0; i < "${#versions[@]}"; i++ )) 87do 88 version="${versions[$i]}" 89 if [[ -n "$3" ]] 90 then 91 size="$3" 92 run_benchmark 93 else 94 for (( j = 0; j < "${#sizes[@]}"; j++ )) 95 do 96 size="${sizes[$j]}" 97 run_benchmark 98 done 99 fi 100done 101 102 103