Here are three different version...
- recursion: Use
make
command to check the answer - iteration: Use
make
command to check the answer - c-code: Translate arm code to c, and use
gprof
to analyze. You can usemake
to run thegprof
script, the results will show inanalysis.txt
. After arranging the data, you can see the example in result.txt. Finally, I use the script and the result shows as following...
gnuplot
> plot "analysis-result.txt"
> set style data lines # connect each dots
> set grid # set background as grid
> set title "fib efficiency" # add title
> replot
> plot "analysis-result.txt" using 1:2 title 'Recursion', \
"analysis-result.txt" using 1:3 title 'Tail-Recursion', \
"analysis-result.txt" using 1:4 title 'Iteration' # plot three data at the same time
> set logscale y; replot # data in y-axis is large, use logscale
> set output "efficiency.png" ; set term png ; replot