{"id":1085,"date":"2021-02-16T22:24:00","date_gmt":"2021-02-17T05:24:00","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=1085"},"modified":"2021-02-11T22:34:16","modified_gmt":"2021-02-12T05:34:16","slug":"api-2-speed-hit","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2021\/02\/16\/api-2-speed-hit\/","title":{"rendered":"API 2 speed hit"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I&#8217;ve seen others comment that they&#8217;ve run into slow downs with API 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve been trying to sqeeze every last ounce from a large app and ran into this one. I&#8217;d suspected it might be a hit but measuring it indeed shows there is a hit &#8211; not tens of seconds but when you want EVERY last microsecond these few add up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My test code is the following<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Const kNumberOfIterations = 1000000\n\nDim startTime As Double\nDim endTime As Double\n\nstartTime = System.Microseconds\n\nFor i As Integer = 0 To kNumberOfIterations\n  \n  Dim s As String = Trim( \"abc\" + Str(i) + \"def\" )\n  \nNext\n\nendTime = System.Microseconds\nSystem.debuglog \" elapsed 1 = \" + Str(endTime - startTime, \"###########0\")\n\nstartTime = System.Microseconds\n\nFor i As Integer = 0 To kNumberOfIterations\n  \n  Dim tmp As String = \"abc\" + Str(i) + \"def\"\n  Dim s As String = tmp.Trim()\n  \nNext\n\nendTime = System.Microseconds\nSystem.debuglog \" elapsed 2 = \" + Str(endTime - startTime, \"###########0\")\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Pretty simple operations but when I run this compiled with default optimization (aggressive doesnt work in the app I&#8217;m building for reasons I have yet to discern) I get the following results<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feb 11 22:22:52\u00a0 My Application[46161] &lt;Warning>:\u00a0 elapsed 1 = 557024<br>Feb 11 22:22:52\u00a0 My Application[46161] &lt;Warning>:\u00a0 elapsed 2 = 573987<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A different of roughly 20,000 microseconds (2 msec)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a small app that I can compile as aggressive this difference shrinks &#8211; but as I noted I cant use aggressive with my app yet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That API forces you to create &amp; use more temporary variables can have an impact. Sticking with the API 1 equivalent _may_ save you time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve seen others comment that they&#8217;ve run into slow downs with API 2. I&#8217;ve been trying to sqeeze every last ounce from a large app and ran into this one. I&#8217;d suspected it might be a hit but measuring it indeed shows there is a hit &#8211; not tens of seconds but when you want &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2021\/02\/16\/api-2-speed-hit\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;API 2 speed hit&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-1085","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=1085"}],"version-history":[{"count":1,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1085\/revisions"}],"predecessor-version":[{"id":1086,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1085\/revisions\/1086"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=1085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=1085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=1085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}