Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!mailrus!uflorida!novavax!proxftl!bill From: bill@proxftl.UUCP (T. William Wells) Newsgroups: comp.misc Subject: Re: Basics of Program Design Summary: Here is how to get execution time stats Message-ID: <440@proxftl.UUCP> Date: 9 Jul 88 19:57:53 GMT References: <807@vax.UUCP> Distribution: na Organization: Proximity Technology, Ft. Lauderdale Lines: 39 In article <807@vax.UUCP>, larry@merlin.cvs.rochester.edu (Lawrence Snyder) writes: > In article <430@proxftl.UUCP> bill@proxftl.UUCP (T. William Wells) writes: > >To make this concrete, let me describe the profile output from a > >typical program after I have finished with it: The first few > >routines take about 5-10% of the execution time apiece. The > >remaining routines take less than a few percent apiece of the > >execution time. > > How did you get these statistics? > (I'm not challenging your numbers. > Obtaining a breakdown of execution time by function call sounds > like a real useful tool.) > > thanx, > lar You bet it is. In fact, often in the late phases of program development, it is one of my most important tools. The tool is called an `execution time profiler', `profiler' for short. They are available on many systems. My primary development system is UNIX. On UNIX, if you want a profile, you compile and link your program with the -p option. When your program runs, and if it terminates by calling exit, a file `mon.out' is created. You then run the program `prof' which creates a nice listing showing the time in each function, the number of times a function is called, and the percent of the total time used by the function. There are other profilers available on UNIX, this is just the easiest to use and interpret. There are similar tools available on other systems, MS-DOS for example; also, it is often possible to roll your own on systems that do not have one. On UNIX, there is also another program `tcov' which is also useful. This program gives you the number of times that each statement of a program is executed. While this does not tell you how long the statements took, it does give you a good idea where to look for inefficiencies.