[George Peter Staplin]: Mar 2, 2004 - I've been curious about where Tcl spends most of its time during the evaluation/execution of scripts, so I learned how to use gprof to profile the tcl core. The steps are: 1. get tcl from cvs here: http://sourceforge.net/projects/tcl/ 2. get the tclbench module from cvs here: http://sourceforge.net/projects/tcllib 3. mkdir tcl_bld ; cd tcl_bld 4. export CC="gcc -pg" 5. ../tcl/unix/configure --prefix=/tmp --disable-shared 6. make 7. create do_bench.sh 8. sh do_bench.sh 9. gprof tclsh test_gmon.out Note: there is no need for 'make install'. Here is the do_bench.sh script: #!/bin/sh for f in ../tclbench/tcl/*.bench do echo $f env SCRIPT="../tclbench/runbench.tcl -verbose -notk -iterations 500 $f" make shell mv gmon.out `basename $f`_gmon.out done The statistics are written upon the exit of the tclsh, and currently tclbench execs each test file, so we can't run a group of tests and have valid results. With NetBSD 2.0 running on a Pentium 4, 1.8 GHz system, the following was the result for '''gprof tclsh array.bench_gmon.out''': Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 11.11 0.01 0.01 20394 0.00 0.00 malloc_bytes 11.11 0.02 0.01 19490 0.00 0.00 TclpAlloc 11.11 0.03 0.01 14686 0.00 0.00 free_bytes 11.11 0.04 0.01 10926 0.00 0.00 memcpy 11.11 0.05 0.01 1290 0.01 0.01 Tcl_ParseBraces 11.11 0.06 0.01 386 0.03 0.03 __stat13 11.11 0.07 0.01 357 0.03 0.03 Tcl_ObjGetVar2 11.11 0.08 0.01 221 0.05 0.05 InitCompiledLocals 11.11 0.09 0.01 94 0.11 0.11 TclCompileReturnCmd 0.00 0.09 0.00 35662 0.00 0.00 TclParseWhiteSpace For further study we may use gcov to get finer results for individual functions. ---- [MS] george, thanks for this. Note that tclbench may not be that well balanced for this particular purpose. In any case, it was not designed for it. Not that I'd know what ''well balanced'' might mean. (after talking with MS in the chat) [George Peter Staplin]: yep, and we will work something out. ([MS] and I discussed using new interps for each test file, rather than new processes.)