mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-07 07:00:49 +03:00
Merge branch 'release/3.13.2' into master
This commit is contained in:
commit
829eed2222
|
@ -1,6 +1,8 @@
|
||||||
recursive-include src/dependency_injector *.py *.pyx *.pxd *.c
|
recursive-include src/dependency_injector *.py *.pyx *.pxd *.c
|
||||||
|
recursive-include tests *.py
|
||||||
include README.rst
|
include README.rst
|
||||||
include CONTRIBUTORS.rst
|
include CONTRIBUTORS.rst
|
||||||
include LICENSE.rst
|
include LICENSE.rst
|
||||||
include requirements.txt
|
include requirements.txt
|
||||||
include setup.py
|
include setup.py
|
||||||
|
include tox.ini
|
||||||
|
|
|
@ -7,6 +7,13 @@ that were made in every particular version.
|
||||||
From version 0.7.6 *Dependency Injector* framework strictly
|
From version 0.7.6 *Dependency Injector* framework strictly
|
||||||
follows `Semantic versioning`_
|
follows `Semantic versioning`_
|
||||||
|
|
||||||
|
3.13.2
|
||||||
|
------
|
||||||
|
- Add additional benchmark of ``Factory`` provider.
|
||||||
|
- Add tests and tox.ini to the distribution, so that they could be used after
|
||||||
|
package is installed (thanks to
|
||||||
|
`Tobias Happ <https://github.com/Gerschtli>`_).
|
||||||
|
|
||||||
3.13.1
|
3.13.1
|
||||||
------
|
------
|
||||||
- Fix typo on "Chained Factories" pattern docs page.
|
- Fix typo on "Chained Factories" pattern docs page.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Dependency injector top-level package."""
|
"""Dependency injector top-level package."""
|
||||||
|
|
||||||
__version__ = '3.13.1'
|
__version__ = '3.13.2'
|
||||||
"""Version number that follows semantic versioning.
|
"""Version number that follows semantic versioning.
|
||||||
|
|
||||||
:type: str
|
:type: str
|
||||||
|
|
90
tests/performance/factory_benchmark_1.py
Normal file
90
tests/performance/factory_benchmark_1.py
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
"""Dependency Injector Factory providers benchmark."""
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
from dependency_injector import providers
|
||||||
|
|
||||||
|
|
||||||
|
N = 1000000
|
||||||
|
|
||||||
|
|
||||||
|
class A(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class B(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class C(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Test(object):
|
||||||
|
def __init__(self, a, b, c):
|
||||||
|
self.a = a
|
||||||
|
self.b = b
|
||||||
|
self.c = c
|
||||||
|
|
||||||
|
|
||||||
|
# Testing Factory provider
|
||||||
|
|
||||||
|
test_factory_provider = providers.Factory(
|
||||||
|
Test,
|
||||||
|
a=providers.Factory(A),
|
||||||
|
b=providers.Factory(B),
|
||||||
|
c=providers.Factory(C),
|
||||||
|
)
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
for _ in range(1, N):
|
||||||
|
test_factory_provider()
|
||||||
|
finish = time.time()
|
||||||
|
|
||||||
|
print(finish - start)
|
||||||
|
|
||||||
|
|
||||||
|
# Testing simple analog
|
||||||
|
|
||||||
|
def test_simple_factory_provider():
|
||||||
|
return Test(a=A(), b=B(), c=C())
|
||||||
|
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
|
for _ in range(1, N):
|
||||||
|
test_simple_factory_provider()
|
||||||
|
finish = time.time()
|
||||||
|
|
||||||
|
print(finish - start)
|
||||||
|
|
||||||
|
# ------
|
||||||
|
# Result
|
||||||
|
# ------
|
||||||
|
#
|
||||||
|
# Python 2.7
|
||||||
|
#
|
||||||
|
# $ python tests/performance/factory_benchmark_1.py
|
||||||
|
# 0.87456202507
|
||||||
|
# 0.879760980606
|
||||||
|
#
|
||||||
|
# $ python tests/performance/factory_benchmark_1.py
|
||||||
|
# 0.949290990829
|
||||||
|
# 0.853044986725
|
||||||
|
#
|
||||||
|
# $ python tests/performance/factory_benchmark_1.py
|
||||||
|
# 0.964688062668
|
||||||
|
# 0.857432842255
|
||||||
|
#
|
||||||
|
# Python 3.7.0
|
||||||
|
#
|
||||||
|
# $ python tests/performance/factory_benchmark_1.py
|
||||||
|
# 1.1037120819091797
|
||||||
|
# 0.999565839767456
|
||||||
|
#
|
||||||
|
# $ python tests/performance/factory_benchmark_1.py
|
||||||
|
# 1.0855588912963867
|
||||||
|
# 1.0008318424224854
|
||||||
|
#
|
||||||
|
# $ python tests/performance/factory_benchmark_1.py
|
||||||
|
# 1.0706679821014404
|
||||||
|
# 1.0106139183044434
|
Loading…
Reference in New Issue
Block a user