On Fri, Aug 29, 2014 at 09:03:52AM +0200, Sven Hartrumpf wrote: > Hi all. > > Is there a Chicken function to reset all counters (to 0) when > a program is run in profile mode? > Background: I need profiling results, but only after my program > reached a specific point and until it terminates.
Unfortunately, there's none that I know of. A nasty trick I sometimes use is to extract "interesting" parts from a procedure and put it into a differently-named one, so that it shows up separate from the rest of the procedures. Depending on the exact layout of your program, you could try and do that, like so (or perhaps improved on with some macrology): (define (proc2 arg1 arg2 ...) ORIGINAL CODE) (define (proc arg1 arg2 ...) (cond ((> counter counter-limit) (proc2 arg1 arg2 ...)) (else (set! counter (add1 counter)) ORIGINAL CODE))) This is extremely ugly, and if you're profiling a large program that won't really be possible. The main problem is that the vector into which profiling information is written is a random name, determined at compile time. I don't really know why this is done, but it does mean you can't easily access it. The only way around this I can come up with is a user compiler pass. It could inspect the name and write it to a global variable, which can then be used by your program to access the profiling vector at runtime, the same way the compiler's generated profiling instrumentation does it. Then you wouldn't need the ugly trick above. Perhaps we can come up with an API for interfacing with the profiler, for (beyond) CHICKEN 5. Cheers, Peter -- http://www.more-magic.net _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users