diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2019-09-30 03:49:12 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2019-09-30 03:49:12 +0300 |
commit | 627ad1b27a2579700e7b0a978caa8598a058da48 (patch) | |
tree | 5330079cb70f9011784a68a8d4e2f6f57dea90c5 | |
parent | add requirements.txt (diff) | |
download | sorting-algorithms-627ad1b27a2579700e7b0a978caa8598a058da48.tar.gz sorting-algorithms-627ad1b27a2579700e7b0a978caa8598a058da48.zip |
add plot.sh (same as plot.bat)
-rw-r--r-- | .gitattributes | 1 | ||||
-rwxr-xr-x | plot.sh | 46 |
2 files changed, 47 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes index 282705f..91bfadd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ * text=auto *.bat text eol=crlf +*.sh text eol=lf @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com> +# This file is part of the "Sorting algorithms" project. +# For details, see https://github.com/egor-tensin/sorting-algorithms. +# Distributed under the MIT License. + +set -o errexit -o nounset -o pipefail + +script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" +script_dir="$( cd -- "$script_dir" && pwd )" +readonly script_dir +script_name="$( basename -- "${BASH_SOURCE[0]}" )" +readonly script_name + +readonly default_iterations=100 +readonly default_min=0 +readonly default_max=200 + +main() { + if [ "$#" -lt 1 ] || [ "$#" -gt 4 ]; then + echo "usage: $script_name ALGORITHM [ITERATIONS [MIN_VALUE [MAX_VALUE]]]" >&2 + exit 1 + fi + + local algorithm="$1" + local iterations="$default_iterations" + [ "$#" -ge 2 ] && iterations="$2" + local min="$default_min" + [ "$#" -ge 3 ] && min="$3" + local max="$default_max" + [ "$#" -ge 4 ] && max="$4" + + local input_kind + for input_kind in best average worst; do + local output_path="${algorithm}_${iterations}_${input_kind}_${min}_${max}.png" + python3 "$script_dir/plot.py" \ + "$algorithm" \ + --input "$input_kind" \ + --min "$min" --max "$max" \ + --iterations "$iterations" \ + --output "$output_path" + done +} + +main "$@" |