Skip to content

Latest commit

 

History

History
21 lines (11 loc) · 751 Bytes

readme.md

File metadata and controls

21 lines (11 loc) · 751 Bytes

PHP C Extension Demo

A performance approach


Primes generation is a clasic mathematical problem which needs to develop increasingly optimal algorithms to solve it, in this case we choose miller-rabin algorithm.

Miller-Rabin is a probabilistic approch to determine if a number is prime or not similar to the Fermat Primality test.


The following demo, show us this algoritm trying to find first 5000 primes with 12 digits using PHP pure implementation and another using a C extension for the calculation process.

screen

As we can see, using a c-extension for the primality test we get a 2927x faster execution.