home *** CD-ROM | disk | FTP | other *** search
-
- Execution time profiler for C programs running under RISCOS 2.00
- ================================================================
- (version 1.00, 04-06-1990)
-
- With the -p[x] option Archimedes C programmers are able to see
- during program execution how often a function is called. This is
- an useful feature when optimising your code.
-
- But sometimes it isn't enough to know how often a function is
- called. More interesting is how much time is spend in one
- particular function. The function which uses most time is a
- candidate for optimising.
-
- Unfortunately the Norcroft C 3.00 compiler hasn't a facility to
- do execution time profiling, so I had to write it myself.
-
-
- How to install it?
- ==================
-
- Define in your source file where 'main' is defined:
-
- #define EXPRO 1
-
- and include then
-
- #include "h.exprofle"
-
- Now call as soon as possible in 'main':
-
- exprofle_init("filename");
-
- With filename is the file where the execution time profiling
- information is written to at the end of program execution.
-
- Compile without the -ff option to include functionnames in the
- code.
-
- After compilation link with the o.exprolib library as the first
- library specified.
-
-
- How does it work?
- =================
-
- After calling 'exprofle_init()' the following happens:
- - check if running under RISCOS 2.00.
- - check if FPEmulator is present and if get its start and end
- address.
- - search for all functionnames and save pointers to them.
- - intercept the undefined instruction vector with a routine
- that saves the return address.
- - register an OS_CallEvery function which is called every 1/100
- of a second.
- - register an atexit function.
-
- Now the program is interrupted every 1/100 of a second and the
- return address is binary searched in an array of functionname
- pointers. When the address interval is found a counter for that
- function is incremented.
- It is possible that the return address lies outside the program
- code, i.e. the program is executing some OS routine.
- When the program uses floating point arithmetic the return
- address could be in the FPEmulator module as well. In that case
- the counter for the fpemulator is incremented, and because we've
- intercepted the undefined instruction vector we know the address
- from where the fpemulator is called. Now this address is binary
- searched in the functionpointer array (in this way we can see how
- much of the total time is spent with floating point calculations
- and at the same time have correct profile values for every
- function).
- In all other cases we increment the 'greaterthan' entry.
-
- When the program exits through 'exit' the execution time
- profiling data will be written to the output file.
-
- The execution time profiling will be correct in most cases but
- you have to be prepared to get some strange results. These
- errors are due to the fact that the libraries (Stubs, Ansilib,
- RISC_OSlib) are compiled with the -ff option to prevent function
- name inclusion.
-
- When your program contains pieces of assembly you have to look
- after the following points:
- - give the code AREA the name: C$$code
- - include functionnames as shown below:
-
- foo_X
- DCB "foo", 0
- ALIGN
- foo_Y
- DCD &ff000000 + foo_Y - foo_X
-
- EXPORT foo
- foo
- ect.
-
-
- If the program is running under the WIMP environment the
- functions: wimp_poll, wimp_pollidle,
- wimp_save_fp_state_on_poll and wimp_corrupt_fp_state_on_poll
- are rewritten to prevent the interruption of other tasks.
- So when linking, o.exprolib has to be earlier in the list of
- libraries than o.RISC_OSlib.
-
-
- Comments or bug reports may be send to:
- =======================================
-
- Ferdinand Oeinck
- Javalaan 25
- 9715 GP Groningen
- The Netherlands
- tel. ++31(0)50 732202
-