Inspired by previous work done by here/.
I use the source code provided on the PI computation.. And performance/timing is measured on the following PC:
16GB RAM
Intel i7-4710HQ CPU @ 2.5GHz
64-bit Windows 10
1TB Samsung SSD
The PI computation does intensive integer (high-accuracy arithmetic) computation rather than floating-point in this case. Number of places for PI digits are set to 10K and 20K. For second runs, the output options are disabled (no file writing or console string), so the timing are mainly for integer computation.
The following modern compilers are tested:
Delphi 7 Delphi 2007 Delphi XE8 x86 Delphi XE8 x64 Delphi 10 x86 Delphi 10 x64 VS2013 cpp x86 VS2013 cpp x64 VS2013 c x86 VS2013 c x64 MINGW 4.8.1 x86 c MINGW 4.8.1 x86 cpp VS2013 C#.NET 4.5 x86 VS2013 C#.NET 4.5 x64 JAVA8 x86 JAVA8 x64 VS2015 cpp x86 VS2015 cpp x64 VS2015 c x86 VS2015 c x64 VS2015 C#.NET 4.5 x86 VS2015 C#.NET 4.5 x64
Results
All Delphi, C++, C, C# compilers set project to RELEASE modes.
Timing Program in Delphi
Timing Source code:
procedure TForm1.Run(const CmdLine: string); var Start, Finish: Cardinal; Dir: string; StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; begin Start := GetTickCount; FillChar(StartupInfo, SizeOf(StartupInfo), 0); StartupInfo.cb := SizeOf(StartupInfo); Dir := ExtractFileDir(Path.Text); if not CreateProcess(PChar(Path.Text), PChar('"' + Path.Text + '" ' + CmdLine), nil, nil, True, 0, nil, PChar(Dir), StartupInfo, ProcessInfo) then RaiseLastOSError; WaitForSingleObject(ProcessInfo.hProcess, INFINITE); Finish := GetTickCount; Results.Lines.Add(IntToStr(Finish - Start)); end; procedure TForm1.RunBtnClick(Sender: TObject); var I: Integer; begin Screen.Cursor := CrHourglass; try Results.Clear; if CmdLines.GetTextLen = 0 then Run('') else for I := 0 to CmdLines.Lines.Count-1 do Run(CmdLines.Lines[I]); finally Screen.Cursor := crDefault; end; end;
Comments
- Modern compilers are in general very good at integer computations. They generally produced highly-optimised code for integer calculations.
- Between different versions of Delphi compilers, the performance does not vary too much. However, the file sizes increases a lot, and x64 version has bigger file size than x86.
- VS2015 Pure C code (both x86 and x64) generally ranks top.
- C codes run faster than CPP.
- JAVA x64 is even faster than compiled Delphi/C++ code.
Pre-compiled Binaries (including Timers)
Pre-compiled Binaries (including Timers)
Download the pre-compiled binaries and share your results!
1-Million PI Digits Lookup/Database
https://helloacm.com/pi/, also you may want to read this post: Integer Performance Comparison for C++, C#, Delphi
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Utilising The Best API for Your Niche
Next Post: How to Show Related Articles using the Matched Content from Google Adsense?
Ha ha.
It is funny to see how they (delphi’s owner, whomever it might be) haven’t changed much in the compiler – since the speed is identical over the years 🙂
Delphi has not focused on the compiler performance. I think their focus is on the IoT, e.g. different mobile platforms.
They should. Performance matters as much as platforms. I use Delphi to process TeraByte files (on Windows only). So, for SOME users performance is important. Plus, there are lots of new/modern cpu instructions that the compiler simply ignores.
Lazarus/FPC is way ahead in this area it doesn’t cost $$$$$ (note the number of digits). 🙂
Well, you can also optimise your core algorithms (where speed matters) using e.g. inline assembler.
Would you please show us the source code of all language that you had demonstrate here? It is really interesting that you mentioned pure C is faster than CPP since C is also valid in CPP and VS compiler (as my understanding) is a CPP compiler.
http://www.tempest-sw.com/benchmark/pi.c