我在 Delphi 中编写了一个简单的 for 循环。\n相同的程序在 Julia 1.6 中快了 7.6 倍。
\nprocedure TfrmTester.btnForLoopClick(Sender: TObject);\nVAR\n i, Total, Big, Small: Integer;\n s: string;\nbegin \n TimerStart;\n\n Total:= 0;\n Big := 0;\n Small:= 0;\n for i:= 1 to 1000000000 DO //1 billion\n begin\n Total:= Total+1;\n if Total > 500000\n then Big:= Big+1\n else Small:= Small+1;\n end;\n\n s:= TimerElapsedS;\n //here code to show Big/Small on the screen\nend;\nRun Code Online (Sandbox Code Playgroud)\nASM 代码对我来说似乎不错:
\nTesterForm.pas.111: TimerStart;\n007BB91D E8DE7CF9FF call TimerStart\nTesterForm.pas.113: Total:= 0;\n007BB922 33C0 xor eax,eax\n007BB924 8945F4 mov [ebp-$0c],eax\nTesterForm.pas.114: Big …Run Code Online (Sandbox Code Playgroud)