Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joelibaceta/php-c-extension-demo

An extension for PHP written in c to demonstrate the performance improvements in the numerical calculation.
https://github.com/joelibaceta/php-c-extension-demo

c-extension miller-rabin php

Last synced: 4 days ago
JSON representation

An extension for PHP written in c to demonstrate the performance improvements in the numerical calculation.

Awesome Lists containing this project

README

        

## 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**](https://en.wikipedia.org/wiki/Miller–Rabin_primality_test) 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](images/screen_record.gif)

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