discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Slow application startup when using a theme


From: Philippe Roussel
Subject: Slow application startup when using a theme
Date: Mon, 09 Jan 2012 00:58:03 +0100

Hi,

I just noticed that applications start a lot slower when using a non
default theme like Neos.

To test this I added a NSLog as the first line of the AppController
-init method and this is what I get (with a hacky method).

With GNUstep theme :

philou@woody:~/sources/SimpleAgenda$ date +%X.%N && 
./SimpleAgenda.app/SimpleAgenda
22:56:17.054406845
2012-01-08 22:56:17.826 SimpleAgenda[14542] AppController -init

With Neos theme :

philou@woody:~/sources/SimpleAgenda$ date +%X.%N && 
./SimpleAgenda.app/SimpleAgenda
23:01:01.740665917
2012-01-08 23:01:05.015 SimpleAgenda[14643] AppController -init

This is almost 3 seconds slower and easily reproducible :(

When I apply the following patch, application startup is under 0.5
second, no matter what theme I choose.

--- Source/NSImage.m    (révision 34462)
+++ Source/NSImage.m    (copie de travail)
@@ -1812,6 +1812,7 @@
 
 + (NSArray *) imageFileTypes
 {
+  return [NSArray arrayWithObjects:@"tif", @"tiff", @"png", @"gif",
@"jpeg", @"jpg", nil];
   return iterate_reps_for_types([NSImageRep registeredImageRepClasses],
                                 @selector(imageFileTypes));
 }

I'm not sure yet why there is a difference between GNUstep and Neos
themes but a lot of work is done in [NSImage +imageNamed:] now that
NSImage can read a lot of file types.

With the following patch I get the startup.log file attached to this
mail. It's a lot of work just for a few bitmaps (and I guess [NSBundle
-pathForResource:ofType:] does a lot of work for each combination too)
but it's about the same amount of work whatever the theme is so there
must be something more going on.

Just for fun, try starting an application using 'strace -e file' for
both GNUstep and Neos themes.

--- Source/NSImage.m    (révision 34462)
+++ Source/NSImage.m    (copie de travail)
@@ -242,6 +242,7 @@
           e = [array objectEnumerator];
           while ((o = [e nextObject]))
             {
+            NSLog(@"local %@ %@", realName, o);
               path = [main_bundle pathForResource: realName 
                                           ofType: o];
               if (path != nil && [path length] != 0)
@@ -261,6 +262,7 @@
              e = [array objectEnumerator];
              while ((o = [e nextObject]))
                {
+                NSLog(@"theme %@ %@", realName, o);
                  path = [[[GSTheme theme] bundle] pathForResource: realName 
                                                            ofType: o];
                  if (path != nil && [path length] != 0)
@@ -285,6 +287,7 @@
               e = [array objectEnumerator];
               while ((o = [e nextObject]))
                 {
+                NSLog(@"system %@ %@", realName, o);
                   path = [NSBundle pathForLibraryResource: realName
                                                   ofType: o
                                               inDirectory: @"Images"];

Philippe

Attachment: startup.log
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]