Saving and saving time

I thought that the time it took to save the settings was wo long, in fact i knew it will take forever (relative) to save the settings at time of writing the logic for it.

# this is slow !!
# because i create each plugin for each config value that is for that plugin
# because i need the config_meta from the class to create the action list
# but i can use the plugins own c obj for saving the value

But i wanted to know how bad or how long this takes, well thankfully i integrated a –profile option. if the profile option is on all functions with the profile descriptor are profiled (more info on that at some other time).

So with profiling on you get this:

*** PROFILER RESULTS ***
_save (/Volumes/HDD/lad1337/workspace/XDM/xdm/web/ajax.py:208)
function called 1 times

4176000 function calls (3930326 primitive calls) in 11.259 seconds

Ordered by: cumulative time, internal time, call count
List reduced from 928 to 40 due to restriction

ncalls tottime percall cumtime percall filename:lineno(function)
1 0.007 0.007 11.260 11.260 ajax.py:208(_save)
159/156 0.051 0.000 5.268 0.034 bases.py:60(__init__)
1 0.007 0.007 5.127 5.127 pm.py:89(cache)
140 0.003 0.000 5.027 0.036 pm.py:330(getInstanceByName)
18 0.001 0.000 4.326 0.240 pm.py:57(_getPylintScore)
18 0.003 0.000 4.319 0.240 lint.py:734(__init__)

Strip that a little but you can see that it takes about 11 seconds to save all settings (and recache the plugins).

Now with a little internal cache that does not need to instantiate every plugin again we get:

*** PROFILER RESULTS ***
_save (/Volumes/HDD/lad1337/workspace/XDM/xdm/web/ajax.py:208)
function called 1 times

         2630607 function calls (2422173 primitive calls) in 6.300 seconds

   Ordered by: cumulative time, internal time, call count
   List reduced from 936 to 40 due to restriction 

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.005    0.005    6.300    6.300 ajax.py:208(_save)
        1    0.004    0.004    4.393    4.393 pm.py:89(cache)
       18    0.001    0.000    3.762    0.209 pm.py:57(_getPylintScore)
       18    0.003    0.000    3.758    0.209 lint.py:734(__init__)
       18    0.005    0.000    3.332    0.185 lint.py:463(check)
       18    0.004    0.000    2.935    0.163 lint.py:549(check_astng_module)

Now we are at around 6 seconds a reduction of 44,04%. Imagen what can be done if we dont recache the plugins or at least dont calculate the pylint score !!

Fork me on GitHub