You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_dtcl@tcl.apache.org by "David N. Welton" <da...@apache.org> on 2001/08/31 23:40:48 UTC

output cacheing

This is preliminary, but:

load ./libCacheOut.so

proc cache { stuff } {
    global CACHE
    if { ! [info exists CACHE($stuff)] } {
	puts "CACHING STUFF"
	opencache
	uplevel 0 $stuff
	set CACHE($stuff) [ closecache ]
    }
    puts $CACHE($stuff)
}

proc falsecache { stuff } {
    uplevel 0 $stuff
}

proc main {} {
    set tm [ time { 
	falsecache { 
            # this is just to make it do some 'real' work
	    source /home/davidw/download/src/tcl/library/http1.0/http.tcl
	    puts Hi
	    puts HO
	    puts "it's off to work we go"
	}   
    } 100 ]
    puts $tm
}
main

1623 microseconds per iteration

switch it to use 'cache' instead of 'falsecache' and

131 microseconds per iteration

I do it by stacking a channel and saving up the output

opencache and closecache turn it on and off, and closecache
regurgitates the saved up output.

Thoughts?  This is alpha quality work...

-- 
David N. Welton
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/