More Xcode 10 Performance Tests
This morning I decided to take another look at the Xcode 10 performance tests on my CryptoQuip puzzle solver, but this time, looking at the Objective-C version and see if the Xcode 10 changes would make it any faster. Turns out, I'm very glad that I did.
I was getting a very odd error on the line:
int main(int argc, const char *argv[]) { return NSApplicationMain(argc, argv); }
the value of argv was causing a SIGABRT - and I just had a feeling it was some setting in the old project file and I needed to clean those up - so after a little bit of updating, it compiled and ran just fine.
I then put in the timing of the call with a few lines:
- (BOOL) attemptWordBlockAttack { // sort the puzzle pieces by the number of possible words they match [[self getPuzzlePieces] sortUsingSelector:@selector(comparePossibles:)]; // ...now run through the standard block attack NSTimeInterval begin = [NSDate timeIntervalSinceReferenceDate]; BOOL ans = [self doWordBlockAttackOnIndex:0 withLegend:[self getStartingLegend]]; NSLog(@"%lu Solution(s) took %f msec", (unsigned long)[[self getSolutions] count], ([NSDate timeIntervalSinceReferenceDate] - begin) * 1000); return ans; }
so that I'd get a similar result as the Swift version - basically, taking everything out of the time in the solution except the attack. That's as close as an apples-to-apples as I could get with the other versions.
What I found out blew me away:
CryptoQuip[87317:16056980] Loaded 25384 words from /Users/drbob/.../words CryptoQuip[87317:16056980] Ready CryptoQuip[87317:16056980] Solving puzzle: 'Fict O ncc bivteclnbklzn O lcpji ukl pt vzglcddp' where b=t CryptoQuip[87317:16056980] 1 Solution(s) took 0.464082 msec CryptoQuip[87317:16056980] Solution found: 'When I see thunderstorms I reach for an umbrella'
Now the times for Clojure were in the 6 msec... and Swift was about 7 msec... but I had to do a double-take on this... I had no idea Objective-C was going to be this fast! I had to compute, by hand, the number of milliseconds since the reference date - January 1, 2001 - just to make sure I was doing the math right. I was right... it was right... I checked the code several times, made sure I wasn't skipping the actual solution... and I wasn't.
Wow... Apple has really outdone themselves on this... sub-msec on the solution. Wow! I have to say this is excellent news in my book. I can live with Swift, and I know it's the future, and it's fast... but it's not this fast, and that's just amazingly cool!