Actions

Benchmarks-watcom

From Gambit wiki

Revision as of 17:55, 1 December 2008 by WikiSysop (talk | contribs)

<texinfo aa=11 bb=22> @deffn procedure fixnum-overflow-exception? @var{obj} @deffnx procedure fixnum-overflow-exception-procedure @var{exc} @deffnx procedure fixnum-overflow-exception-arguments @var{exc}

Fixnum-overflow-exception objects are raised by some of the fixnum specific procedures when the result is larger than can fit in a fixnum. The parameter @var{exc} must be a fixnum-overflow-exception object.

The procedure @code{fixnum-overflow-exception?} returns @code{#t} when @var{obj} is a fixnum-overflow-exception object and @code{#f} otherwise.

The procedure @code{fixnum-overflow-exception-procedure} returns the procedure that raised @var{exc}.

The procedure @code{fixnum-overflow-exception-arguments} returns the list of arguments of the procedure that raised @var{exc}.

For example:

@smallexample > @b{(define (handler exc)

   (if (fixnum-overflow-exception? exc)                                        
       (list (fixnum-overflow-exception-procedure exc)                         
             (fixnum-overflow-exception-arguments exc))                        
       'not-fixnum-overflow-exception))}

> @b{(with-exception-catcher

   handler                                                                     
   (lambda () (fx* 100000 100000)))}

(#<procedure #2 fx*> (100000 100000)) @end smallexample

@end deffn

@deffn {special form} time @r{@i{expr}}

The @code{time} special form evaluates @i{expr} and returns the result. As a side effect it displays a message on the interaction channel which indicates how long the evaluation took (in real time and cpu time), how much time was spent in the garbage collector, how much memory was allocated during the evaluation and how many minor and major page faults occured (0 is reported if not running under UNIX).

For example:

@frog

@smallexample > @b{(define (f x)

   (let loop ((x x) (lst '()))
     (if (= x 0)
         lst
         (loop (- x 1) (cons x lst)))))}

> @b{(length (time (f 100000)))} (time (f 100000))

   683 ms real time
   558 ms cpu time (535 user, 23 system)
   8 collections accounting for 102 ms real time (70 user, 5 system)
   6400160 bytes allocated
   no minor faults
   no major faults

100000 @end smallexample

@end deffn

</texinfo>