From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Thu Jun 02 2011 - 06:27:04 CDT

On Thu, Jun 2, 2011 at 4:39 AM, Benjamin Hall
<benjamin.hall_at_bioch.ox.ac.uk> wrote:
> Hi
>
> I've encountered an odd problem with for loops in tcl in VMD, whereby over the course of extended loops (>10000 iterations) in subroutines the individual loops seem to become slower as the loop progresses. The scripts are typically looping through frames in a trajectory in a manner similar to the below structure
>
> for { set i 0 }  { $i < [molinfo top get numframes] } { incr i } {
>        some_other_function $i
>        puts "."
> }
>
> As the loop progresses, the rate of printing "." visibly slows. I've not noticed any memory leaks (the some_other_function typically contains several atomselect commands),  but I've seen this happen in a couple of unrelated scripts which do the same kind of looping through frames. If I rerun the loop, the initial speeds appear the same. I've not been able to sensibly benchmark the script, though I would if someone could suggest a benchmarking tool for tcl. Has anyone else observed this kind of behaviour, and could anyone suggest a likely cause/solution for the problem?

no, i have not seen this. however, there are a lot of possible reasons
why "some_other_function" can slow down over the course of iterations,
e.g. by inefficiently walking or searching growing lists. memory leaks
is a less likely option, but the slowdown would be drastic when you run
out of available memory and go into swap.

timing in tcl can be done with the "clock" command. check out the
tcl/tk wiki (you can find it from www.tcl.tk) which contains lots of little
useful codelets and discussions on how to do things in tcl.

cheers,
     axel.

> Thanks
>
> Ben
> ************************************************************************
> Benjamin A. Hall
> Structural Bioinformatics & Computational Biochemistry Unit / OCISB
> University of Oxford
> http://sbcb.bioch.ox.ac.uk/hall.php
> +44 (0)1865 613304
> benjamin.hall_at_bioch.ox.ac.uk
>
>
>
>
>
>
>
>
>

-- 
Dr. Axel Kohlmeyer
akohlmey_at_gmail.com  http://goo.gl/1wk0
Institute for Computational Molecular Science
Temple University, Philadelphia PA, USA.