This is the mail archive of the
mailing list for the Guile project.
Re: time macro
- To: Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Subject: Re: time macro
- From: Nicolas Neuss <Nicolas dot Neuss at IWR dot Uni-Heidelberg dot De>
- Date: 17 Jul 2000 14:12:08 +0200
- Cc: guile at sourceware dot cygnus dot com
- References: <firstname.lastname@example.org>
Harvey J. Stein posted some benchmarking for scheme procedures on this
list some time ago. It is called "wrappers.scm". I've used it
sometimes and it worked quite well.
Below is the beginning of the file I have. Perhaps there is a more
;;; wrappers.scm - Library for wrapping functions & executing forms.
;;; Useful for implementing tracing & profiling (as is
;;; done here).
;;; Version 0.8
;;; Copyright (c) 1995 Harvey J. Stein (email@example.com)
;;; This code is GPLed. For more info
;;; For tracing:
;;; (with-tracing (foo bar baz) (baz 19))
;;; Executes (baz 19), while tracing entries to & exits from foo,
;;; bar & baz.
;;; For profiling:
;;; (with-profiling ...)
;;; Same story, but keeps track of execution times and prints
;;; results at end.
;;; In general:
;;; (with-wrappers wrapper starter ender simlist form)
;;; wrapper should be a function which takes 2 args, a symbol & a
;;; fcn. It should return a fcn. Starter & ender are thunks.
;;; Simlist is a list of symbols. Form is an sexp to evaluate.
;;; Basically, the defn of all symbols s in simlist are replaced with
;;; (wrapper 's s). Then starter is called, form is executed,
;;; ender is called, and the result of form is returned. The
;;; execution of ender is guaranteed by the use of dynamic-wind.
;;; Undoing the damage of wrapper is guaranteed by fluid-let.
;;; Bugs/To do:
;;; -Requires call to clock to be added to Stk - I added it to
;;; posix, even though it's not really posix (but it is ANSI C).
;;; If clock doesn't exist, I use the time from
;;; (get-internal-info). But, this causes lots of extra consing
;;; (and extra time taken up in the profiling).
;;; -How can I wrap symbols defined in children environments?
;;; -Would be nice to add some more statistics to the profiling
;;; (such as # of cells consed, etc).
;;; -Profiling should also figure out how much time of the time
;;; spent in a subroutine is actually spent amongst the children...
;;; -Maybe dynamic-wind should also be used in wrappers - On the one
;;; hand this would enable tracing to track continuation usage, but
;;; on the other hand, it might introduce alot of overhead.