{"id":4806,"date":"2017-12-26T14:17:13","date_gmt":"2017-12-26T06:17:13","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4806"},"modified":"2017-12-26T14:17:13","modified_gmt":"2017-12-26T06:17:13","slug":"%e6%9d%82%e8%b0%88-%e4%b8%80%e4%b8%aa%e5%85%b3%e4%ba%8e-as-%e7%9a%84%e5%b0%8f%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4806","title":{"rendered":"[\u6742\u8c08] \u4e00\u4e2a\u5173\u4e8e as \u7684\u5c0f\u6d4b\u8bd5"},"content":{"rendered":"<p>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">procedure TForm1.Button1Click(Sender: TObject);\r\nvar\r\n  B:TButton;\r\n  I: Integer;\r\n  ATime:Cardinal;\r\nbegin\r\n  ATime:=GetTickCount;\r\n  for I := 0 to 99999999 do\r\n    B:=Sender as TButton;\r\n  ATime:=GetTickCount-ATime;\r\n  Memo1.Lines.Add('as time:'+IntToStr(ATime)+'ms');\r\n  ATime:=GetTickCount;\r\n  for I := 0 to 99999999 do\r\n    B:=TButton(Sender);\r\n  ATime:=GetTickCount-ATime;\r\n  Memo1.Lines.Add('direct time:'+IntToStr(ATime)+'ms');\r\nend;<\/pre>\n<p>\u597d\u5427\uff0c\u6211\u4eec\u5df2\u7ecf\u77e5\u9053 ASender \u80af\u5b9a\u662f\u4e00\u4e2a TButton \u7c7b\u578b\u7684\u5bf9\u8c61\uff0c\u7136\u540e\u5faa\u73af\u4e86 1 \u4ebf\u6b21\uff0c\u4ee5\u4fbf\u653e\u5927\u95ee\u9898\u3002\u6211\u4eec\u770b\u4e0b\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<blockquote><p>as time:578ms<br \/>\ndirect time:219ms<\/p><\/blockquote>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u7528 as \u8f6c\u6362\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u8981\u6bd4\u76f4\u63a5\u5f3a\u5236\u8f6c\u6362\u591a\u82b1\u4e86 2.7 \u500d\u7684\u65f6\u95f4\u3002\u6839\u636e\u7edf\u8ba1\u7ed3\u70b9\u6765\u8bf4\uff0c1 \u4ebf\u6b21\u9700\u8981 578 ms\uff0c\u6bcf\u767e\u4e07\u6b21\u4e5f\u5dee\u8ddd\u5728 3.6 ms \u5de6\u53f3\uff0c\u5b9e\u9645\u5dee\u8ddd\u5e76\u6ca1\u6709\u6bd4\u4f8b\u770b\u8d77\u6765\u7684\u90a3\u4e48\u5413\u4eba\u3002\u4e0d\u8fc7\u5728\u7a0b\u5e8f\u4e2d\uff0c\u5982\u679c\u4f60\u660e\u786e\u77e5\u9053\u7c7b\u578b\u7684\u60c5\u51b5\u4e0b\uff0c\u7528\u5f3a\u5236\u8f6c\u6362\u597d\u8c61\u6ca1\u4ec0\u4e48\u574f\u7247\uff0c\u8fd8\u5c11\u8f93\u5165\u4e24\u4e2a\u7a7a\u683c\u7684\u5de5\u4f5c\u91cf\uff0c\u770b\u8d77\u6765\u86ee\u5212\u7b97\u7684\uff0c\u4e0d\u8fc7\u7531\u4e8e()\u7684\u4f4d\u7f6e\uff0c\u5b9e\u9645\u8f93\u5165\u53ef\u80fd\u4f1a\u66f4\u6162\u4e00\u4e9b\u3002\u597d\u5427\uff0c\u5904\u5973\u5ea7\u7684\u4eba\u7ea0\u7ed3\u53bb\u5427\uff0c\u6211\u4e2a\u4eba\u8fd8\u662f\u89c9\u5f97\u5f3a\u8f6c\u66f4\u597d\u4e00\u70b9\u70b9\uff0c\u868a\u5b50\u518d\u5c0f\u4e5f\u662f\u8089\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u5982\u4e0b\uff1a procedure TFor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8,21],"tags":[],"class_list":["post-4806","post","type-post","status-publish","format-standard","hentry","category-delphi","category-misc"],"views":3680,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4806"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4806\/revisions"}],"predecessor-version":[{"id":4807,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4806\/revisions\/4807"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}