Tests the performance impact of using native libraries to replace CPU-intensive parts of Python programs. (A follow-up to my previous project on benchmarking programming languages.)
For the F# implementation I used pythonnet which provides an interoperability layer bridging .NET and the CPython interpreter.
The Python code requires CPython 3.5 or newer and the PyPI packages in requirements.txt
.
The F# code requires .NET Framework 4.8.
Once both are installed, build the F# library. After that you should be good to run any of the scripts listed below.
python3 main.py [iterations] [implementation]
(Where implementation
is python
or fsharp
.)
python3 test.py
python3 fsharp_implementation.py
These results where collected on a desktop with an AMD Ryzen 5 2600X using 50,000 iterations.
Python: 72.1551 seconds
F#: 61.6405 seconds