Skip to content

Commit

Permalink
Change -c|--clean to -f|--fresh & fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
myaaghubi committed Aug 10, 2023
1 parent e5a4652 commit 6cc1cd0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ $ bash benchmark.sh
## Commands

```bash
# some options
# use bash benchmark.sh --help
$ bash benchmark.sh -f -rapache -rnginx -t ...

# run composer update for frameworks
$ bash update.sh

Expand All @@ -157,6 +161,7 @@ To specify frameworks, put them with `-t ...` after each command:

```bash
# supported for `setup.sh`, `benchmark.sh`, `update.sh`, `clean.sh`, and `clear-cache.sh`
# not required to put / after the name, just use the tab in your terminal
# bash benchmarks.sh --help -h
$ bash benchmark.sh -t laravel-10.0/ slim-4.11/ ...
...
Expand Down
2 changes: 1 addition & 1 deletion base/hello_world.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ do
# continue
# fi

if [ "$param_clean" = true ]; then
if [ "$param_fresh" = true ]; then
bash clean.sh
bash setup.sh -t "$fw"
fi
Expand Down
11 changes: 9 additions & 2 deletions base/option_target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function showHelp()
{
cat << HEREDOC
Usage: bash check.sh [-t pure-php/ slim-*]
Usage: bash check.sh [-t pure-php slim-*]
Optional Arguments:
-h, --help Show this help message and exit
Expand All @@ -30,6 +30,7 @@ IFS=';'
params=(`php ./libs/strreplace.php " -" ";-" " ${paramsin}"`)
IFS=$oldIFS

init_benchmark=true
for option in "${params[@]}"
do
case "$option" in
Expand All @@ -41,13 +42,19 @@ do
fi
;;
-h|--help)
init_benchmark=false
showHelp;
;;
""|" ")
;;
*)
init_benchmark=false
echo "\"${option}\" not available"
exit 1
;;
esac
done
done

if [ "$init_benchmark" = false ]; then
exit 1
fi
22 changes: 13 additions & 9 deletions benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function showHelp()
{
cat << HEREDOC
Usage: bash benchmark.sh [-c] [-rapache] [-t pure-php slim]
Usage: bash benchmark.sh [-f] [-rapache] [-t pure-php slim]
Optional Arguments:
-c, --clean Clean all frameworks and install the target framework -fresh install- before benchmark.
-f, --fresh Clean all frameworks and install the target framework -fresh install- before benchmark.
-h, --help Show this help message and exit
-rapache, --restart-apache Restart apache "sudo systemctl restart apache2" before each benchmark.
-rnginx, --restart-nginx Restart apache "sudo systemctl restart nginx" before each benchmark.
Expand All @@ -35,7 +35,7 @@ HEREDOC
}

export param_targets="$frameworks_list"
export param_clean=false
export param_fresh=false
export param_restart_apache=false
export param_restart_nginx=false

Expand All @@ -48,11 +48,12 @@ IFS=';'
params=(`php ./libs/strreplace.php " -" ";-" " ${paramsin}"`)
IFS=$oldIFS

init_benchmark=true
for option in "${params[@]}"
do
case "$option" in
-c|--clean)
param_clean=true
-f|--fresh)
param_fresh=true
;;
-rapache|--restart-apache)
param_restart_apache=true
Expand All @@ -68,18 +69,21 @@ do
fi
;;
-h|--help)
init_benchmark=false
showHelp;
;;
""|" ")
;;
*)
init_benchmark=false
echo "\"${option}\" not available"
exit 1
;;
esac
done

sh ./base/hello_world.sh

echo ''
php ./libs/show_results_table.php
if [ "$init_benchmark" = true ]; then
sh ./base/hello_world.sh
echo ''
php ./libs/show_results_table.php
fi

0 comments on commit 6cc1cd0

Please sign in to comment.