mprof v1.0 - a simple Matlab profiler. To use these files for profiling Matlab code, do like this: Initially, copy mprof to a directory in your $PATH and copy ctic.m and ctoc.m to a directory in your matlabpath. Each time you want to profile an m-file, e.g. calc.m, do like this: Execute 'mprof calc.m c.m' at your unix prompt. Now c.m contains all code from calc.m interleaved with calls to the profiling code. Do the following inside matlab: >> c(your_ordinary_calc_arguments) >> global CPU_TIMES CPU_TIMES(i) will contain the time spent at line i in calc.m. Suggestions: >> find(CPU_TIMES==max(CPU_TIMES)) will give you the number of the line taking the longest time to execute. >> [y,i]=sort(-CPU_TIMES) will give you the line numbers in i sorted in descending order by the total time >> bar(CPU_TIMES/sum(CPU_TIMES)*100) will give you a percentage graph KNOWN BUGS: Doesn't handle multi-line assignment, e.g. A= [ 3 4 5; 3 6 7]; For feedback, send an email to niclas@cs.umu.se. Have fun! /Niclas -- Niclas Borlin email: niclas@cs.umu.se Department of Computing Science phone: (+46) 90-166832 Umea University fax: (+46) 90-166126 S-901 87 Umea, SWEDEN lat/long: 63.49 N, 20.19 E