Table of Contents
1. Introduction
C++ Builder has a great IDE, includes compilers for Win32, Win64, Android and iOS. C++Builder has both CLANG Enhanced C/C++ Compiler and a Embarcadero’s new Bcc C/C++ Compiler. It also features a modern, high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform UI development. You can develop GUI based applications easily, as it comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs. There is a free C++ Builder Community Edition that can be used by students, beginners and startups with limitations.
You can download the free C++ Builder Community Edition here: https://www.embarcadero.com/products/cbuilder/starter. Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://www.embarcadero.com/products/cbuilder.
In this post we compared VCL and FMX compilers in Counting Prime Numbers. Prime number function is also tested in Delphi and in Python here on Youtube with Kiriakos Vlahos. We inspired from this video and we try to do same test same function in C++.
Finding Prime Numbers in C++ is explained detailed well in this Easily Learn To Find Prime Numbers In Modern C++ post.
2. System Description
PC setup that we used in tests here is;
OS: Windows 10 64 bit (Version 2004)
CPU: AMD Ryzen 7 1800X (3.6 Ghz)
RAM: 16 GB DDR4
GPU: Nvidia GTX 1080Ti
Drive: Samsung 960 Pro M.2 SSD
3. Counting Prime Numbers Example in C++ Builder VCL ( for CLANG and Bcc Compiler)
In this test we used our previous codes on VCL to check VCL performance of C++ Builder on the it’s new CLANG Compiler and on the classic, new Borland Bcc Compiler. Note that we made change here in our previous codes by adding (float) at this line
[crayon-673fd3197e2af781083084/]This (float)x definition is needed to run codes on classic Borland compiler, otherwise it gives Ambiguity error on sqrt() function because of x is integer while it needs a float number.
4. Counting Prime Numbers Example in C++ Builder FMX (for CLANG and Bcc Compiler)
This is a C++ Builder example to find number of prime numbers in a given range. Note that it runs with a Form which has a Button and a Memo box to display output.
5. Results in C++ Builder FMX (FireMonkey) framework with CLANG Compiler
6. Results in C++ Builder FMX (FireMonkey) framework with Bcc Compiler
7. Results in C++ Builder VCL framework with CLANG Compiler
8. Results in C++ Builder VCL framework with Bcc Compiler
Conclusion
According to all tests and results above, there are minor changes in different tests of a same cases, about +- 5 +-15 milliseconds. Here below, all results are listed in a table;
In conclusion, C++ Builder CLANG has best scores in 64bits compilation on both VCL and FMX (FireMonkey) frameworks, Bcc compiler looks slightly faster than CLANG compiler on both 32bits VCL and FMX frameworks. If we compare VCL and FMX frameworks, we can say both VCL and FMX frameworks has same performance on both CLANG and Bcc Compilers. This is expected because in these tests we don’t use any UI elements.
Please see out other tests on Dev C++, GNU C/C++, VS-Code With GNU C/C++, Python