NEW July 13. 2021! Uploaded multithreaded variant of 1 bit per prime candidate. Performance: AMD TR 1950x 32 bit: 85000+ passes, 64 bit: 129200+ passes

NEW July 4. 2021! Reuploaded 1 bit per prime candidate 64 bit optimized solution (Project2), which performs more than twice as fast as the 32 bit solution.

David Plummer, previously working for years with Microsoft programming various sorts of features, like the Task Manager, the Space Cadet Pin Ball game, SmartCache and more, has started a contest, trying to figure out which programming language is the “fastest”.

Obviously “fastest” can mean many things, but in this contest, it means how many times can an application compiled or run by one of 45+ different compilers/interpreters find all prime numbers between 2 and 1 million within 10 seconds.

Delphi is represented as one of the 45+ environments, and today he released a comparison between Delphi, Pascal (in the form of FreePascal and ADA which syntax wise looks similar to Pascal. For various reasons Delphi is actually not benchmarked (I know Jim McKeeth is working on a solution for them to include Delphi… licensing etc. stuff).

You can follow him at Daves Garage on Youtube here: https://www.youtube.com/c/DavesGarage/playlists

The latest (and first of several) video is here: https://www.youtube.com/watch?v=tQtFdsEcK_s&list=PLF2KJ6Gy3cZ5Er-1eF9fN1Hgw_xkoD9V1&index=6&ab_channel=Dave%27sGarage

The code being used in the benchmark can be found at GitHub here: https://github.com/PlummersSoftwareLLC/Primes

Delphi is as said represented with a solution, but I could not help myself, than try to produce an optimized version.

In fact I made a couple, one based on the same 1 byte per 1 prime candidate as the original solution, and one which use only 1 bit per 1 prime candidate (as the contest actually require).

I have uploaded both to GitHub as candidates, but my pull requests has to be accepted before they will show up in the main tree.

For that reason I have also made them available for others to play with (and perhaps optimize further) on Google Drive here: https://drive.google.com/drive/folders/1ljI4AlaL7WUfmTNeUoEfzWZFwVcImZL6?usp=sharing

It contains two Delphi files, Project1.dpr and Project2.dpr.

Project1.dpr use 1 byte per 1 prime candidate, but runs approximately 100% faster than the original.

Project2.dpr use 1 bit per 1 prime candidate, but runs approximately 10% faster than the original.

Follow the project and do what you can to provide faster prime generators to make Delphi shine 🙂


5 thoughts on “Delphi Sieve candidates to the fastest programming language contest”
  1. Downloaded from google and adapted for FPC/Lazarus. Only compiled for 64 bit. Project1 best result 14760. Project2 best result 11102.
    Multi-threaded version of Project1 on 16 core cpu best result 98200.

    1. Was it the multithreaded version I provided? Then it is actually a 1 bit per 1 prime candidate, which is what Project2 also does. Project1 is 1 byte per 1 prime candidate.

  2. In your sieve you set num := factor * 3 SHR 1;
    while actually you can set num = sqr(factor) because the square of the factor is the first bit you will find which is a multiple of factor with its bit set to 1.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.