AnsweredAssumed Answered

Script Gets Slower Every Time I Run it.

Question asked by wadef on May 24, 2010


Script Gets Slower Every Time I Run it.


I'm new to FMP, and databases in general, although I have many years experience in assembler & Fortran (I'm showing my age here).  I'm using FMP 11 on a Mac with OS 10.6.3

I've generated a number of related tables (Activities Register, Accounts, Securities List, Price History & others), and populated them with test data and written several scripts, one of which summarizes the holdings of the entire portfolio by account (number & name of each security held, etc, for each account).

The portfolio summary script runs rather slowly, so I've been trying to optimize both my database structure, and my script.  In doing so, I run repeated tests with the same script and the same data, deleting all records at the start, and timing the execution speed several times in order to get an average execution time.

I am very surprised to discover that if I run the script repeatedly, the execution speed slows down each time I run it!  For example, on 6 consecutive runs, I timed the execution (in this order) at 23, then 26, then 30, 43, 48, and 53 seconds!!!  If I quit FMP and restart it, I'm back to the 23 second range for the first run.

As a test to confirm this, I wrote a quick timing-test script that simply cycles through 6 different layouts 500 times (using Go to Layout).  The first time I ran it, it took 24 Seconds, the second time, 29 seconds, third time 35 seconds!!!!!!!  Again, if I Quit from FMP and restart, the execution time for the first run is back down to 24 seconds.  This script does absolutely nothing, except switch from one layout to another, then loop back to the start.

I also ran the timing-test script 5 times (from a fresh re-start), then ran the portfolio summary script afterwards.  The execution time of the portfolio summary test run was 52 seconds (as opposed to a normal 22-23 for first run), so I presume that whatever is causing the slow-down is not isolated to a single script - each execution of one script slows down the subsequent execution of another script.

Can anyone explain what might be happening here?  Am I filling up some FMP stack with extraneous garbage each time I run?  Is there some way to prevent this?