[gambit-list] Profiler or coverage tool?

Bradley Lucier lucier at math.purdue.edu
Wed Oct 1 17:21:11 EDT 2008


In January 2005, Guillaume Germaine announced his statistical profiler  
for Gambit, available here:

http://www.iro.umontreal.ca/~germaing/statprof.html

I've looked at some reports from a run with a recent gambit, and it  
doesn't seem to give me a reasonable results (or maybe I'm not using  
it right).

After requesting help from Marc for a test-coverage tool, he sent me  
the program at the end of the file, which just dumps line locations of  
statements in the file to stderr, so it isn't all that helpful as is  
(but it shows how to hook it into the interpreter).

I'm really looking for a code coverage tool; does anyone have one, or  
plan to write one?

Brad

 From Marc:

;= 
= 
= 
= 
= 
= 
========================================================================

; File: "coverage.scm", Time-stamp: <2005-04-27 12:12:52 feeley>

; Copyright (C) 2005 by Marc Feeley, All Rights Reserved.

;= 
= 
= 
= 
= 
= 
========================================================================

; This is a simple test coverage system for Gambit 4.0 that uses the
; interpreter's single stepping infrastructure.  The test coverage can
; only be done on interpreted code.  However, the test coverage system
; (this file) can either be compiled or not, but if it is not compiled
; the program's execution will be much slower.  When the test coverage
; system is compiled the program's execution is roughly 4 times slower
; than normal. When the test coverage system is interpreted the
; program's execution is roughly 20 times slower than normal.
;
; Here's a sample use:
;
;  % gsi coverage.scm -
;  > (coverage-on)
;  > (if #f (+ 1 2 3) 4)
;  (console)@2.5
;  (console)@2.18
;  4
;  > (coverage-off)
;  (console)@3.2
;  (console)@3.1
;  > (if #f (+ 1 2 3) 4)
;  4

;= 
= 
= 
= 
= 
= 
========================================================================

(define-macro (coverage-system-setup)

  (define coverage-system-code
    '(let ()

       (define (step-handler leapable? $code rte execute-body . other)
         (hit (##code-locat $code))
         (##apply execute-body (##cons $code (##cons rte other))))

       (define (hit locat)
         (if locat
             (begin
               ; the statistics could be tallied and displayed in a
               ; more user-friendly way than just dumping them to stderr
               (##display-locat locat #t ##stderr-port)
               (##newline ##stderr-port))))

       (let ((new-stepper
              (##vector (##vector step-handler
                                  step-handler
                                  step-handler
                                  step-handler
                                  step-handler
                                  step-handler
                                  step-handler)
                        #f
                        #f
                        #f
                        #f
                        #f
                        #f
                        #f)))
         (set! ##main-stepper new-stepper))))

  `(if (##interp-procedure? (lambda () 0)) ; compiled or interpreted?

       (begin
         (set! ##main-stepper (##no-stepper)) ; don't step coverage  
system!
         (##eval ',coverage-system-code))

       (begin
         ,coverage-system-code)))

(define (coverage-on)
  (##step-on))

(define (coverage-off)
  (##step-off))

(coverage-system-setup)

;= 
= 
= 
= 
= 
= 
========================================================================



More information about the Gambit-list mailing list