slow startup of wxPython application

I have a small unfinished application that seems to have an
unexpectedly slow time to start up (by clicking on the Python icon for
the main frame of the application) given how small it is. From a cold
start of not having been run recently, it takes ~37 seconds for the
app to load from the time of clicking to when it is displayed. Then,
after it is closed and reopened, it pops up very quickly, a few
seconds.

This seems really slow to me for such a dinky application, and I've
seen this with many small apps I've made. This application is a frame
(~700 lines) which imports a frame (~500 lines) and a framepanel (~300
lines). It is running with the following specs:

- wxPython 2.8.7.1
- Python 2.5
- Windows XP, SP2
- Gateway Tablet PC, 1.7 Ghz, 512 Meg RAM
- and it import a fair number of modules,
including bigger things like matplotlib and sqlite

I realize that in running the application I am also having to run the
Python interpreter. But are there ways to try to reduce the start up
time of the application or any wxPython application? Some of the
intended apps are to be run at start-up of the computer, and so it is
less important, but generally I'd still like to know ways to reduce
this time if possible.

Thanks,
CM

You cannot reduce the startup time if you do not know where this time is spent.

Investigate to find the culprit. Once you discover your time consuming bits, you can investigate alternatives.

Peter.

···

On Wed, Apr 16, 2008 at 7:13 AM, C M cmpython@gmail.com wrote:

I have a small unfinished application that seems to have an

unexpectedly slow time to start up (by clicking on the Python icon for

the main frame of the application) given how small it is. From a cold

start of not having been run recently, it takes ~37 seconds for the

app to load from the time of clicking to when it is displayed. Then,

after it is closed and reopened, it pops up very quickly, a few

seconds.

This seems really slow to me for such a dinky application, and I’ve

seen this with many small apps I’ve made. This application is a frame

(~700 lines) which imports a frame (~500 lines) and a framepanel (~300

lines). It is running with the following specs:

  • wxPython 2.8.7.1

  • Python 2.5

  • Windows XP, SP2

  • Gateway Tablet PC, 1.7 Ghz, 512 Meg RAM

  • and it import a fair number of modules,

including bigger things like matplotlib and sqlite

I realize that in running the application I am also having to run the

Python interpreter. But are there ways to try to reduce the start up

time of the application or any wxPython application? Some of the

intended apps are to be run at start-up of the computer, and so it is

less important, but generally I’d still like to know ways to reduce

this time if possible.

Thanks,

CM


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


There is NO FATE, we are the creators.

Hi Chaelon,

C M wrote:

I have a small unfinished application that seems to have an
unexpectedly slow time to start up (by clicking on the Python icon for
the main frame of the application) given how small it is. From a cold
start of not having been run recently, it takes ~37 seconds for the
app to load from the time of clicking to when it is displayed. Then,
after it is closed and reopened, it pops up very quickly, a few
seconds.

This seems really slow to me for such a dinky application, and I've
seen this with many small apps I've made. This application is a frame
(~700 lines) which imports a frame (~500 lines) and a framepanel (~300
lines). It is running with the following specs:

- wxPython 2.8.7.1
- Python 2.5
- Windows XP, SP2
- Gateway Tablet PC, 1.7 Ghz, 512 Meg RAM
- and it import a fair number of modules,
including bigger things like matplotlib and sqlite

I realize that in running the application I am also having to run the
Python interpreter. But are there ways to try to reduce the start up
time of the application or any wxPython application? Some of the
intended apps are to be run at start-up of the computer, and so it is
less important, but generally I'd still like to know ways to reduce
this time if possible.
  

I just tried my app on my Vista machine, it starts up in about 7 seconds, if I close it and start it again it takes about 5 seconds. On my older Win2000 machine it takes about 15 seconds (512MB Ram, Pentium III), second start is about 8 or 9 seconds). The initial start up brings up the mainframe which has a menu, two sub frames which are hidden (until user selects which one he wants to work with), it connects to the db (Firebird SQL - server version on my Vista machine, FB embedded on the Win2000). As you can see from my numbers there is space for improvement.

As Peter suggested you need to narrow down what is causing this slow start up, I suspect that matplotlib is one of the culprits (I use it too but it only gets loaded if/when user actually wants to look at some graphics).

I know you use Boa, so a good and easy way of finding the culprit(s) is to use the Profiler, i.e. run your application from within Boa by clicking on the Red Arrow with a magnifier glass, after it started just close it and wait a little bit Boa will then show a tap with the times per module and function and .....

I had problems with load times too, so when I did Profile my app I found that e.g. all the dbg statements in masked controls would take a lot of time, after mentioning this to Will Sadkin he made sure that the released version of the controls had all the dbg stuff commented out. I also noticed that my frames which had multiple notebooks and quite a lot of controls on them took a lot of time, so I decided to delay the loading of most of them until the user actually wants to use them. This means a little delay when he uses one but speed up the initial load.

Hope this helps
Werner

C M schrieb:

I have a small unfinished application that seems to have an
unexpectedly slow time to start up (by clicking on the Python icon for
the main frame of the application) given how small it is. From a cold
start of not having been run recently, it takes ~37 seconds for the
app to load from the time of clicking to when it is displayed. Then,
after it is closed and reopened, it pops up very quickly, a few
seconds.

This seems really slow to me for such a dinky application, and I've
seen this with many small apps I've made. This application is a frame
(~700 lines) which imports a frame (~500 lines) and a framepanel (~300
lines). It is running with the following specs:

- wxPython 2.8.7.1
- Python 2.5
- Windows XP, SP2
- Gateway Tablet PC, 1.7 Ghz, 512 Meg RAM
- and it import a fair number of modules,
including bigger things like matplotlib and sqlite

I realize that in running the application I am also having to run the
Python interpreter. But are there ways to try to reduce the start up
time of the application or any wxPython application? Some of the
intended apps are to be run at start-up of the computer, and so it is
less important, but generally I'd still like to know ways to reduce
this time if possible.

Thanks,
CM
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

same to me using wxpython & matplotlib:
cold: 24 sec, profiling 4.621 CPU seconds
after: 5 sec, profiling 3.344 CPU seconds

using
if __name__ == '__main__':
    import cProfile
    cProfile.run('main()')
to start the application

- wxPython 2.8.7.1
- Python 2.5
- Windows XP, SP2 on PentiumIV, 2.2 GH, 1 GB Ram

Unless I missed something important I don't see how profiling could help to track it down. I guess the main part of the time is used to load the libraries into memory which are still hold there after the first run.

I don't like it, but can live with it as the application itself runs smoothly.

Jürgen

I wish use this function that open a unix terminal and write a command calling it from a gui (double click on an item of a listbox) but it doesn't work.Instead if I lunch it from the python idle it works.In the gui not even an error is generate.What do you think about it?

Regards
Giuseppe

def OnPrintLabel(sCode,sPrint):

         HOST = "localhost"
         user = 'user1'
         password = 'pass'

         tn = telnetlib.Telnet(HOST)

         tn.read_until("login: ")
         tn.write(user + "\n")
         tn.read_until("Password: ")
         tn.write(password + "\n")
         tn.write("ls \n")

         sParameter = "/usr/bla/bin/gedit `/usr/bla/bin/bla 30` 80 5 F
%s %s \n" %(sCode,sPrint)
         #print sParameter
         tn.write(sParameter)

         tn.write("exit\n")

#call from this in the gui

def OnItemSelected(self, event):

         #pdb.set_trace()
         item = event.GetItem()
         sCode =item.GetText()
         sCode =str(sCode)
         sPrint = 'A29'
         data.OnPrintLabel(sCode,sPrint)

Paul McNett schrieb:

C M wrote:

I'm left wondering about what is happening in the "cold" vs. "warm"
loads. If I exit all Python applications on my computer, and then
reload the program, it loads very quickly, so something is still in
memory. Is it the Python interpreter? What explains this? And how
can one zero things out such that one is back to a cold start (without
having to restart the computer)?

It is a feature of Windows that keeps the program image around for awhile so it doesn't need to reload on subsequent startups. You can control it by deleting the associated image file, which is in a hidden folder in the system directory somewhere, the name of which is escaping me right now and a google search wasn't successful.

Paul
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi Paul,
I guess you meant the Windows System Cache:
http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/core/fnec_evl_acks.mspx?mfr=true
and for optimisation:
http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/core/fnec_evl_acks.mspx?mfr=true
but the cache is stored in pagefile.sys and you can't delete parts of it.
Jürgen