{"id":234,"date":"2007-05-12T17:18:48","date_gmt":"2007-05-12T15:18:48","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/get-cpu-speed\/"},"modified":"2007-05-12T17:18:50","modified_gmt":"2007-05-12T15:18:50","slug":"get-cpu-speed","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/get-cpu-speed\/","title":{"rendered":"Get CPU speed"},"content":{"rendered":"<p>I&#8217;m not all that good at ASM so what all this does<br \/>\nI can&#8217;t explain in much detail.<\/p>\n<p>[code lang=&#8221;delphi&#8221;]function TForm1.GetCpuSpeed: Extended;<br \/>\nvar<br \/>\n  t: DWORD;<br \/>\n  mhi, mlo, nhi, nlo: DWORD;<br \/>\n  t0, t1, chi, clo, shr32: Comp;<br \/>\nbegin<br \/>\n  shr32 := 65536;<br \/>\n  shr32 := shr32 * 65536;<br \/>\n  t := GetTickCount;<br \/>\n  while t = GetTickCount do begin end;<br \/>\n  asm<br \/>\n    DB 0FH<br \/>\n    DB 031H<br \/>\n    mov mhi,edx<br \/>\n    mov mlo,eax<br \/>\n  end;<\/p>\n<p>  while GetTickCount < (t + 1000) do begin end;\n  asm\n    DB 0FH\n    DB 031H\n    mov nhi,edx\n    mov nlo,eax\n  end;\n  chi := mhi; if mhi < 0 then chi := chi + shr32;\n  clo := mlo; if mlo < 0 then clo := clo + shr32;\n  t0 := chi * shr32 + clo;\n  chi := nhi; if nhi < 0 then chi := chi + shr32;\n  clo := nlo; if nlo < 0 then clo := clo + shr32;\n  t1 := chi * shr32 + clo;\n  Result := (t1 - t0) \/ 1E6;\nend;\n\n\n\/\/and example call\nprocedure TForm1.Button1Click(Sender: TObject);\nbegin\n label1.Caption := FloatToStr(GetCpuSpeed) + 'mhz';\nend;\n[\/code]\n\n[tags]Delphi, System[\/tags]\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m not all that good at ASM so what all this does I can&#8217;t explain in much detail. [code lang=&#8221;delphi&#8221;]function TForm1.GetCpuSpeed: Extended; var&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,113],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-3M","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/234"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=234"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/234\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}