Archive for the 'iOnTV' Category

Maccamp Boston

May 9th, 2008 by awk

Maccamp Boston is this weekend - and I’m going to go !

I’m not quite sure what I’ll talk about (if asked) probably iOnTV (which I’ve done a bunch of work on recently - though it’s not reflected on the website).

Oh - and I got VMware to donate some copies of Fusion for a raffle too !

 

Category: VMware, iOnTV | No Comments »

It’s all in the predicate

February 26th, 2008 by awk

Although I might have ordered a new zippy MacBook - my old PowerBook is still proving its use: highlighting pieces of code that are just too slow.

In the iOnTV UI application the schedule grid (list of what’s on) is a critical part of the main window. I noticed that as the database of program information got larger scrolling performance in the schedule grid (going backwards/forwards in time) was terribly slow on my PowerBook.

A little time with Shark showed that I was spending 80% my time in the ‘fetch schedules on a station between two times’ method. This method used a simple predicate to fetch only those schedule details fulfilling the arguments :

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"((station == %@) AND (time >= %@) AND (time <= %@)) OR ((station == %@) AND (time < %@) AND (endTime > %@))", self, startDate, endDate, self, startDate, startDate];

A little thinking about it and I realized that the logic was overly complex and could be simplified :

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(station == %@) AND (((time >= %@) AND (time <= %@)) OR ((endTime >= %@) AND (endTime <= %@)))", self, startDate, endDate, startDate, endDate];

I don’t need to compare against the station more than once - start with everything on this station, and then consider only those things that start between the two times or end between the two times.

Result ? The fetch is now less than 10% of the CPU usage when changing the start time in the schedule grid ! Much better ! I still have a couple more optimizations to make - but watch those predicates !

Category: Development, iOnTV | No Comments »