{"id":4048,"date":"2014-03-30T07:21:23","date_gmt":"2014-03-30T07:21:23","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/using-xcode-and-instruments-to-improve-iphone-app-performance-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:21:23","modified_gmt":"2014-03-30T07:21:23","slug":"using-xcode-and-instruments-to-improve-iphone-app-performance-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/using-xcode-and-instruments-to-improve-iphone-app-performance-collection-of-common-programming-errors\/","title":{"rendered":"Using XCode and instruments to improve iPhone app performance-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m not sure instruments is your best bet here. Instruments samples your code, meaning (amongst other things) that it affects timing. If you want to know how long a loop takes then you should put something in the code to calculate and either retain or display the amount of time each loop is taking.<\/p>\n<p>An actual runtime can be had by:<\/p>\n<pre><code>\/\/ activity starts\nNSDate* startTime = [NSDate date];\n\n\/\/ activity ends\nNSLog(@\"time elapsed this loop is %f\", fabs([startTime timeIntervalSinceNow]));\n<\/code><\/pre>\n<p>Getting an average is easy if you have a time calculated per loop since you can sum the times, count the loops and divide before you display the average.<\/p>\n<p><em>Anything<\/em> in your loop affects the timing, of course, but this affects in a minimal way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m not sure instruments is your best bet here. Instruments samples your code, meaning (amongst other things) that it affects timing. If you want to know how long a loop takes then you should put something in the code to calculate and either retain or display the amount of time each loop is taking. An [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4048","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4048"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4048\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}