function Test2: integer; var s: integer; begin s := 0; TParallel.&For(1, MAXN, procedure(i: integer) begin if (IsPrime(i) = 1) then begin // memory barrier AtomicIncrement(s); end end); Result := s; end;
----------------------------------------------
-
Delphi XE7 新增并行库-TParallel 能充分利用CPU性能,很多人的测试还是停留在简单 for i=0 to10000000 do ...... 这种低级代码上面。
作者还特别强调:and it is not about the language war! 喜欢喷人还是绕道吧。
----------------------------------------------
Delphi4Linux Delphi三层/FireDAC 技术群:734515869 http://www.cnblogs.com/rtcmw
Re: Integer Performance Test: Delphi 10.2 Tokyo outperforms Visual C++ and Visual C# « Reply #14 on: March 28, 2017, 08:20:38 pm » I have written a FreePascal version of the test, but using native threads directly and recompiled same application with Delphi. Tests conditions, configuration and target is the same. I have attached updated sources for FreePascal, Delphi and MSVC. If you recompile each of them, please make sure to enable all optimization options: Release mode for Delphi, "-OoLoopUnroll -OoFastMath -Sv -CpCoreI -CfSSE42 -OpCoreI" for FreePascal and "-Ox -GL" for MSVC.
Still, I'm getting the following figures for x64 target:
FreePascal (native): ~2400 ms FreePascal (MTProcs): ~2840 ms Delphi (native): ~1030 ms Delphi (TParallel class): ~1010 ms MSVC: ~710 ms
Out of curiousity, for 32-bit target:
FreePascal (native): ~1030 ms Delphi (TParallel class): ~1030 ms MSVC: ~730 ms
Srcstorm, I'm not sure how really you are compiling the projects, but your benchmarks seem to be rather bogus - in both 32-bit and 64-bit tests, Delphi is roughly 50% slower than the corresponding Visual Studio compiled project in both Win32 and Win64 targets. Also, I doubt there have been any changes to Win32/Win64 Delphi compilers in Delphi 10.2 (in fact, likely since the release of Delphi XE 2), so performance tests are likely the same for both Delphi 10.1 and 10.2.
However, I still don't understand why FreePascal version is much slower for x64 target, even when using threads directly via "TThread" class. Perhaps the issue is actually in how "IsPrime" function gets compiled?
----------------------------------------------
-