{"id":7674,"date":"2018-09-24T08:51:00","date_gmt":"2018-09-24T13:51:00","guid":{"rendered":"https:\/\/bobbeaty.com\/wp\/?p=7674"},"modified":"2018-09-25T03:58:39","modified_gmt":"2018-09-25T08:58:39","slug":"more-xcode-10-performance-tests","status":"publish","type":"post","link":"https:\/\/bobbeaty.com\/wp\/archives\/7674","title":{"rendered":"More Xcode 10 Performance Tests"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bobbeaty.com\/wp\/wp-content\/uploads\/2007\/09\/xcode.jpg\" alt=\"xcode.jpg\" title=\"xcode.jpg\" border=\"0\" width=\"128\" height=\"128\" style=\"float:right;\" \/><\/p>\n<p>This morning I decided to take another look at the Xcode 10 performance tests on my <a href=\"https:\/\/github.com\/drbobbeaty\/CryptoQuip\">CryptoQuip<\/a> 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 <strong><em>very glad<\/em><\/strong> that I did.<\/p>\n<p>I was getting a very odd error on the line:<\/p>\n<pre class=\"objc\" style=\"font-family:monospace;\"><span style=\"color: #a61390;\">int<\/span> main<span style=\"color: #002200;\">&#40;<\/span><span style=\"color: #a61390;\">int<\/span> argc, <span style=\"color: #a61390;\">const<\/span> <span style=\"color: #a61390;\">char<\/span> <span style=\"color: #002200;\">*<\/span>argv<span style=\"color: #002200;\">&#91;<\/span><span style=\"color: #002200;\">&#93;<\/span><span style=\"color: #002200;\">&#41;<\/span>\n<span style=\"color: #002200;\">&#123;<\/span>\n    <span style=\"color: #a61390;\">return<\/span> NSApplicationMain<span style=\"color: #002200;\">&#40;<\/span>argc, argv<span style=\"color: #002200;\">&#41;<\/span>;\n<span style=\"color: #002200;\">&#125;<\/span><\/pre>\n<p>the value of <tt>argv<\/tt> was causing a <tt>SIGABRT<\/tt> - 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.<\/p>\n<p>I then put in the timing of the call with a few lines:<\/p>\n<pre class=\"objc\" style=\"font-family:monospace;\"><span style=\"color: #002200;\">-<\/span> <span style=\"color: #002200;\">&#40;<\/span><span style=\"color: #a61390;\">BOOL<\/span><span style=\"color: #002200;\">&#41;<\/span> attemptWordBlockAttack\n<span style=\"color: #002200;\">&#123;<\/span>\n    <span style=\"color: #11740a; font-style: italic;\">\/\/ sort the puzzle pieces by the number of possible words they match<\/span>\n    <span style=\"color: #002200;\">&#91;<\/span><span style=\"color: #002200;\">&#91;<\/span>self getPuzzlePieces<span style=\"color: #002200;\">&#93;<\/span> sortUsingSelector<span style=\"color: #002200;\">:<\/span><span style=\"color: #a61390;\">@selector<\/span><span style=\"color: #002200;\">&#40;<\/span>comparePossibles<span style=\"color: #002200;\">:<\/span><span style=\"color: #002200;\">&#41;<\/span><span style=\"color: #002200;\">&#93;<\/span>;\n    <span style=\"color: #11740a; font-style: italic;\">\/\/ ...now run through the standard block attack<\/span>\n    NSTimeInterval begin <span style=\"color: #002200;\">=<\/span> <span style=\"color: #002200;\">&#91;<\/span><a href=\"http:\/\/developer.apple.com\/documentation\/Cocoa\/Reference\/Foundation\/Classes\/NSDate_Class\/\"><span style=\"color: #400080;\">NSDate<\/span><\/a> timeIntervalSinceReferenceDate<span style=\"color: #002200;\">&#93;<\/span>;\n    <span style=\"color: #a61390;\">BOOL<\/span> ans <span style=\"color: #002200;\">=<\/span> <span style=\"color: #002200;\">&#91;<\/span>self doWordBlockAttackOnIndex<span style=\"color: #002200;\">:<\/span><span style=\"color: #2400d9;\">0<\/span> withLegend<span style=\"color: #002200;\">:<\/span><span style=\"color: #002200;\">&#91;<\/span>self getStartingLegend<span style=\"color: #002200;\">&#93;<\/span><span style=\"color: #002200;\">&#93;<\/span>;\n    NSLog<span style=\"color: #002200;\">&#40;<\/span><span style=\"color: #bf1d1a;\">@<\/span><span style=\"color: #bf1d1a;\">&quot;%lu Solution(s) took %f msec&quot;<\/span>,\n        <span style=\"color: #002200;\">&#40;<\/span><span style=\"color: #a61390;\">unsigned<\/span> <span style=\"color: #a61390;\">long<\/span><span style=\"color: #002200;\">&#41;<\/span><span style=\"color: #002200;\">&#91;<\/span><span style=\"color: #002200;\">&#91;<\/span>self getSolutions<span style=\"color: #002200;\">&#93;<\/span> count<span style=\"color: #002200;\">&#93;<\/span>,\n        <span style=\"color: #002200;\">&#40;<\/span><span style=\"color: #002200;\">&#91;<\/span><a href=\"http:\/\/developer.apple.com\/documentation\/Cocoa\/Reference\/Foundation\/Classes\/NSDate_Class\/\"><span style=\"color: #400080;\">NSDate<\/span><\/a> timeIntervalSinceReferenceDate<span style=\"color: #002200;\">&#93;<\/span> <span style=\"color: #002200;\">-<\/span> begin<span style=\"color: #002200;\">&#41;<\/span> <span style=\"color: #002200;\">*<\/span> <span style=\"color: #2400d9;\">1000<\/span><span style=\"color: #002200;\">&#41;<\/span>;\n    <span style=\"color: #a61390;\">return<\/span> ans;\n<span style=\"color: #002200;\">&#125;<\/span><\/pre>\n<p>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.<\/p>\n<p>What I found out blew me away:<\/p>\n<pre>\nCryptoQuip[87317:16056980] Loaded 25384 words from \/Users\/drbob\/...\/words\nCryptoQuip[87317:16056980] Ready\nCryptoQuip[87317:16056980] Solving puzzle: 'Fict O ncc bivteclnbklzn O lcpji ukl pt\n                               vzglcddp' where b=t\nCryptoQuip[87317:16056980] 1 Solution(s) took 0.464082 msec\nCryptoQuip[87317:16056980] Solution found: 'When I see thunderstorms I reach for an\n                               umbrella'\n<\/pre>\n<p>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 <strong><em>no idea<\/em><\/strong> 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.<\/p>\n<p>Wow... Apple has really outdone themselves on this... sub-msec on the solution. Wow! I have to say this is <em>excellent<\/em> 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!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;m very glad that I did. I was getting a very odd error on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,9,4],"tags":[],"class_list":["post-7674","post","type-post","status-publish","format-standard","hentry","category-apple","category-cocoa-coding","category-open-source-software"],"_links":{"self":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/7674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/comments?post=7674"}],"version-history":[{"count":2,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/7674\/revisions"}],"predecessor-version":[{"id":7676,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/7674\/revisions\/7676"}],"wp:attachment":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/media?parent=7674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/categories?post=7674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/tags?post=7674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}