11#! /bin/sh
22
3+ if [ ! ` which php` ]; then
4+ echo " php not found."
5+ exit 1;
6+ fi
7+
38if [ ! ` which wrk` ]; then
4- echo " wrk not found."
9+ echo " WRK not found."
510 exit 1;
611fi
712
813if [ ! ` which curl` ]; then
9- echo " curl not found."
14+ echo " CURL not found."
1015 exit 1;
1116fi
1217
13- base=" http://127.0.0.1/php-frameworks-bench"
18+ function showHelp()
19+ {
20+ cat << HEREDOC
1421
15- if [ $# -eq 0 ]; then
16- # include frameworks list
17- . ./list.sh
18- export targets=" $list "
19- else
20- export targets=" ${@%/ } "
21- fi
22+ Usage: bash benchmark.sh [-c] [-rapache] [-t pure-php laravel-10]
23+
24+ Optional Arguments:
25+ -c, --clean NUM Clean all frameworks and install the target framework -fresh install- before benchmark.
26+ -h, --help Show this help message and exit
27+ -rapache, --restart-apache Restart apache "sudo systemctl restart apache2" before each benchmark.
28+ -rnginx, --restart-nginx Restart apache "sudo systemctl restart nginx" before each benchmark.
29+ -t, --targets Specify your target frameworks for benchmarking.
30+
31+ HEREDOC
32+ }
33+
34+ . ./list.sh
35+ export param_targets=" $list "
36+ export param_clean=false
37+ export param_restart_apache=false
38+ export param_restart_nginx=false
39+
40+ insputs=" ${@%/ } "
41+ IFS=' ;'
42+ params=(` php ./libs/strreplace.php " -" " ;-" " ${insputs} " ` )
2243
23- cd base
44+ for option in " ${params[@]} "
45+ do
46+ case " $option " in
47+ -c|--clean)
48+ param_clean=true
49+ ;;
50+ -rapache|--restart-apache)
51+ param_restart_apache=true
52+ ;;
53+ -rnginx|--restart-nginx)
54+ param_restart_nginx=true
55+ ;;
56+ -t* |--targets* )
57+ arg_=${option// --targets / }
58+ arg_=${arg_// -t / }
59+ param_targets=" $arg_ "
60+ ;;
61+ -h|--help)
62+ showHelp;
63+ ;;
64+ " " )
65+ ;;
66+ * )
67+ echo " ${option} not available"
68+ ;;
69+ esac
70+ done
2471
25- sh hello_world.sh " $base "
72+ sh ./base/ hello_world.sh
2673
27- php ../bin /show_results_table.php
74+ php ./libs /show_results_table.php
0 commit comments