tombenner / nui

Style iOS apps with a stylesheet, similar to CSS
MIT License
3.76k stars 461 forks source link

slowness in parsing comparing to old nui #318

Open AliOmari opened 8 years ago

AliOmari commented 8 years ago

i'm actually using the old nui in my app and it's very fast in parsing, but when i convert to the current nui i actually noticed slowness in performance 0.3 s vs 2.1 s (parsing time is seconds)

can anyone help me in this issue ?

timbodeit commented 8 years ago

I have a pretty large nss file in one of my applications and we have been seeing some performance issues as well. I've been meaning to look into this, but didn't find the time for it yet.

Can you provide an example .nss file and the two versions of nui where you compared the performance?

Another idea I had was to see if it was possible to "pre-compile" any .nss files in the resource bundle at build time since they are likely being loaded during application launch. Would that help you as well?

AliOmari commented 8 years ago

mmm my nss file is about 3500 line. old nui parsing time about 0.3 seconds. new nui parsing time about 2.1 seconds.

i can't determine the version of old nui but the old one doesn't have media queries and doesn't uses the same way in parsing.

old one

\- (NSMutableDictionary_)getStylesFromPath:(NSString_)path { NSString\* content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; return [self consolidateRuleSets:[self getRuleSets:content] withTopLevelDeclarations:[self getTopLevelDeclarations:content]]; }

the new one

\- (NSMutableDictionary_)getStylesFromFile:(NSString_)fileName { NSString\* path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"nss"]; NSAssert1(path != nil, @"File \"%@\" does not exist", fileName); NSString\* content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; NUIStyleSheet *styleSheet = [self parse:content]; return [self consolidateRuleSets:styleSheet]; }
timbodeit commented 8 years ago

Please have a look through the history of that file and see if you can find your version.

AliOmari commented 8 years ago

the first commit on Dec 5, 2012 my old nui (NUIStyleParser) looks like it

timbodeit commented 8 years ago

Alright... I'll try to find the time to look into this.

AliOmari commented 8 years ago

the parsing way completely different between the two versions, but it's very hard to me to get back to the old nui because i need media queries, and i really need every mili second in my application

AliOmari commented 8 years ago

@timbodeit can you tell me how to do the parsing for one time ?! i mean to put the pre-compiled file into resource bundle