BookmarkSubscribeRSS Feed

Community Trekker


Aug 29, 2016

Does using namespace-qualified variables slow down execution?

I have a function that I need to be fast, as I'm using it in a column formula on tables with 500K-21M rows.

Trying to optimize speed, I did some benchmarking. I got the speed up as fast as I could, and it was still slow. 

My function used some matrices as lookup tables. I loaded these into memory in a prior step, in my session startup script. I was loading them into namespace-qualified variables to keep from cluttering global namespace. 

As a Hail-Mary, I tried loading them instead into global (non-namespace-qualified) variables.

To my surprise, the body of the function executed in less than 1/10th the time just by using global variables to hold my static lookup tables, rather than namespace-qualified ones. To emphasize, these tables are already resident in memory before the function is called; it's not about populating them, it's just about referencing them.

Do other people have this experience?

(I've attached a screenshot of the debug screen so you can see the comparative timings. I'm just comparing the body of the functions here, so you don't see the function wrapper.)

Debug screen.jpg