Integer Computation Efficiency Comparisons Between Modern Compilers – Case Study – PI Computation (Delphi, Java, C, C++)


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.

performance-comparisons-between-modern-compilers Integer Computation Efficiency Comparisons Between Modern Compilers - Case Study - PI Computation (Delphi, Java, C, C++) optimization performance comparison programming languages

performance-comparisons-between-modern-compilers

performance-comparisons-between-modern-compilers-chart Integer Computation Efficiency Comparisons Between Modern Compilers - Case Study - PI Computation (Delphi, Java, C, C++) optimization performance comparison programming languages

performance-comparisons-between-modern-compilers-chart

Timing Program in Delphi

delphi-timing Integer Computation Efficiency Comparisons Between Modern Compilers - Case Study - PI Computation (Delphi, Java, C, C++) optimization performance comparison programming languages

delphi-timing

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

  1. Modern compilers are in general very good at integer computations. They generally produced highly-optimised code for integer calculations.
  2. 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.
  3. VS2015 Pure C code (both x86 and x64) generally ranks top.
  4. C codes run faster than CPP.
  5. JAVA x64 is even faster than compiled Delphi/C++ code.

Pre-compiled Binaries (including Timers)

Pre-compiled Binaries (including Timers) 6K Integer Computation Efficiency Comparisons Between Modern Compilers - Case Study - PI Computation (Delphi, Java, C, C++) optimization performance comparison programming languages

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) —

GD Star Rating
loading...
660 words
Last Post: Utilising The Best API for Your Niche
Next Post: How to Show Related Articles using the Matched Content from Google Adsense?

The Permanent URL is: Integer Computation Efficiency Comparisons Between Modern Compilers – Case Study – PI Computation (Delphi, Java, C, C++)

6 Comments

  1. Auttasak L.

Leave a Reply