C++C++11C++14C++17Language Feature

Interesting C++ Builder Compiler Counting Prime Number Benchmarks

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

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


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

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++17Language FeatureLearn C++

How To Use Skia Images in C++ Builder?

C++C++17Code SnippetGame DevelopmentLanguage FeatureLearn C++

What Is Skia In Modern C++?

C++C++17Learn C++

How To Use Skia in C++ Builder 12?

C++C++17C++20Introduction to C++Language FeatureLearn C++Syntax

Learn How To Use Clamp (std::clamp) In Modern C++ 17 and Beyond

Worth reading...
C++ Is 9.4 Times Faster Than Python In Prime Number Test