{"id":4431,"date":"2012-03-08T22:21:19","date_gmt":"2012-03-09T03:21:19","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=4431"},"modified":"2012-03-08T22:21:22","modified_gmt":"2012-03-09T03:21:22","slug":"bnrtimeblock","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2012\/03\/08\/bnrtimeblock\/","title":{"rendered":"BNRTimeBlock"},"content":{"rendered":"<p><a href=\"http:\/\/weblog.bignerdranch.com\/?p=316\">Mark Dalrymple<\/a>:<\/p>\n<blockquote cite=\"http:\/\/weblog.bignerdranch.com\/?p=316\"><p>Timing how long a block of code takes is a useful tool.  Maybe you&#8217;re choosing between two different calls that do similar things and you&#8217;re wondering which one is faster.  If one is faster, is it faster-enough to make any difference?  The usual techniques involve using a profiler like Instruments, or calling a time function like <code>gettimeofday()<\/code> before and after your code and calculating the delta.  Those of us on mach-based systems like iOS and OS X can use <code>mach_absolute_time()<\/code>, which is the finest-grained timepiece available on the system.<\/p><\/blockquote>\n<p>Instruments has its place, but I often prefer to the low-tech approach of adding logging and timing code directly to my app or unit tests. You can leave logging on while using the app normally, measure things on other people&rsquo;s Macs, and keep a record of everything in version control.<\/p>","protected":false},"excerpt":{"rendered":"<p>Mark Dalrymple: Timing how long a block of code takes is a useful tool. Maybe you&#8217;re choosing between two different calls that do similar things and you&#8217;re wondering which one is faster. If one is faster, is it faster-enough to make any difference? The usual techniques involve using a profiler like Instruments, or calling a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-4431","post","type-post","status-publish","format-standard","hentry","category-programming-category"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/4431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=4431"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/4431\/revisions"}],"predecessor-version":[{"id":4432,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/4431\/revisions\/4432"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=4431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=4431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=4431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}