Skip to content

Commit

Permalink
Update benchmark numbers in README.
Browse files Browse the repository at this point in the history
  • Loading branch information
scoder committed Nov 29, 2024
1 parent 487a687 commit de68ce9
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,38 @@ simplicity, accuracy and safety. Clearly not in terms of speed, though,
given the cdecimal accelerator in Python 3.3+.

``quicktions`` is an adaptation of the original ``fractions`` module
(as included in CPython 3.13a3) that is compiled and optimised with
(as included in CPython 3.13) that is compiled and optimised with
`Cython <https://cython.org/>`_ into a fast, native extension module.

Compared to the standard library ``fractions`` module of CPython,
computations in ``quicktions`` are about
Compared to the standard library ``fractions`` module of CPython 3.12,
computations in ``quicktions`` are about 3-4x faster.

- 10x faster in Python 2.7 and 3.4
- 6x faster in Python 3.5
- 3-4x faster in Python 3.10

Compared to the ``fractions`` module in CPython 3.10, instantiation of a
``Fraction`` in ``quicktions`` is also
Instantiation of a ``Fraction`` in ``quicktions`` is also

- 5-15x faster from a floating point string value (e.g. ``Fraction("123.456789")``)
- 3-5x faster from a floating point value (e.g. ``Fraction(123.456789)``)
- 2-4x faster from an integer numerator-denominator pair (e.g. ``Fraction(123, 456)``)
- 2-5x faster from an integer numerator-denominator pair (e.g. ``Fraction(123, 456)``)

We provide a set of micro-benchmarks here:

https://github.com/scoder/quicktions/tree/master/benchmark

As of quicktions 1.12, the different number types and implementations compare
as follows in CPython 3.10:
As of quicktions 1.19, the different number types and implementations compare
as follows in CPython 3.12 (measured on Ubuntu Linux):

.. code-block::
Average times for all 'create' benchmarks:
float : 36.17 us (1.0x)
Decimal : 111.71 us (3.1x)
Fraction : 111.98 us (3.1x)
PyFraction : 398.80 us (11.0x)
float : 33.55 us (1.0x)
Fraction : 116.02 us (3.5x)
Decimal : 132.22 us (3.9x)
PyFraction : 361.93 us (10.8x)
Average times for all 'compute' benchmarks:
float : 4.53 us (1.0x)
Decimal : 16.62 us (3.7x)
Fraction : 72.91 us (16.1x)
PyFraction : 251.93 us (55.6x)
float : 3.24 us (1.0x)
Decimal : 17.28 us (5.3x)
Fraction : 77.04 us (23.8x)
PyFraction : 166.38 us (51.2x)
While not as fast as the C implemented ``decimal`` module in Python 3,
``quicktions`` is about 15x faster than the Python implemented ``decimal``
Expand Down

0 comments on commit de68ce9

Please sign in to comment.