-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:MongoEngine/mongoengine into fix_…
…performance_issue_count
- Loading branch information
Showing
70 changed files
with
2,269 additions
and
1,273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
fail_fast: false | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: debug-statements | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- repo: https://github.com/ambv/black | ||
rev: 21.4b2 | ||
rev: 23.9.1 | ||
hooks: | ||
- id: black | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.9.1 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- importlib_metadata<5 | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v2.14.0 | ||
rev: v3.14.0 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py36-plus] | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.8.0 | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
StringField, | ||
) | ||
|
||
mongoengine.connect(db="mongoengine_benchmark_test") | ||
mongoengine.connect(db="mongoengine_benchmark_test", w=1) | ||
|
||
|
||
def timeit(f, n=10000): | ||
|
@@ -38,34 +38,34 @@ def init_book(): | |
author_email="[email protected]", | ||
) | ||
|
||
print("Doc initialization: %.3fus" % (timeit(init_book, 1000) * 10 ** 6)) | ||
print("Doc initialization: %.3fus" % (timeit(init_book, 1000) * 10**6)) | ||
|
||
b = init_book() | ||
print("Doc getattr: %.3fus" % (timeit(lambda: b.name, 10000) * 10 ** 6)) | ||
print("Doc getattr: %.3fus" % (timeit(lambda: b.name, 10000) * 10**6)) | ||
|
||
print( | ||
"Doc setattr: %.3fus" | ||
% (timeit(lambda: setattr(b, "name", "New name"), 10000) * 10 ** 6) # noqa B010 | ||
% (timeit(lambda: setattr(b, "name", "New name"), 10000) * 10**6) # noqa B010 | ||
) | ||
|
||
print("Doc to mongo: %.3fus" % (timeit(b.to_mongo, 1000) * 10 ** 6)) | ||
print("Doc to mongo: %.3fus" % (timeit(b.to_mongo, 1000) * 10**6)) | ||
|
||
print("Doc validation: %.3fus" % (timeit(b.validate, 1000) * 10 ** 6)) | ||
print("Doc validation: %.3fus" % (timeit(b.validate, 1000) * 10**6)) | ||
|
||
def save_book(): | ||
b._mark_as_changed("name") | ||
b._mark_as_changed("tags") | ||
b.save() | ||
|
||
print("Save to database: %.3fus" % (timeit(save_book, 100) * 10 ** 6)) | ||
print("Save to database: %.3fus" % (timeit(save_book, 100) * 10**6)) | ||
|
||
son = b.to_mongo() | ||
print( | ||
"Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10 ** 6) | ||
"Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10**6) | ||
) | ||
|
||
print( | ||
"Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10 ** 6) | ||
"Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10**6) | ||
) | ||
|
||
def create_and_delete_book(): | ||
|
@@ -75,7 +75,7 @@ def create_and_delete_book(): | |
|
||
print( | ||
"Init + save to database + delete: %.3fms" | ||
% (timeit(create_and_delete_book, 10) * 10 ** 3) | ||
% (timeit(create_and_delete_book, 10) * 10**3) | ||
) | ||
|
||
|
||
|
@@ -101,9 +101,9 @@ def init_company(): | |
) | ||
|
||
company = init_company() | ||
print("Big doc to mongo: %.3fms" % (timeit(company.to_mongo, 100) * 10 ** 3)) | ||
print("Big doc to mongo: %.3fms" % (timeit(company.to_mongo, 100) * 10**3)) | ||
|
||
print("Big doc validation: %.3fms" % (timeit(company.validate, 1000) * 10 ** 3)) | ||
print("Big doc validation: %.3fms" % (timeit(company.validate, 1000) * 10**3)) | ||
|
||
company.save() | ||
|
||
|
@@ -112,17 +112,17 @@ def save_company(): | |
company._mark_as_changed("contacts") | ||
company.save() | ||
|
||
print("Save to database: %.3fms" % (timeit(save_company, 100) * 10 ** 3)) | ||
print("Save to database: %.3fms" % (timeit(save_company, 100) * 10**3)) | ||
|
||
son = company.to_mongo() | ||
print( | ||
"Load from SON: %.3fms" | ||
% (timeit(lambda: Company._from_son(son), 100) * 10 ** 3) | ||
% (timeit(lambda: Company._from_son(son), 100) * 10**3) | ||
) | ||
|
||
print( | ||
"Load from database: %.3fms" | ||
% (timeit(lambda: Company.objects[0], 100) * 10 ** 3) | ||
% (timeit(lambda: Company.objects[0], 100) * 10**3) | ||
) | ||
|
||
def create_and_delete_company(): | ||
|
@@ -132,7 +132,7 @@ def create_and_delete_company(): | |
|
||
print( | ||
"Init + save to database + delete: %.3fms" | ||
% (timeit(create_and_delete_company, 10) * 10 ** 3) | ||
% (timeit(create_and_delete_company, 10) * 10**3) | ||
) | ||
|
||
|
||
|
Oops, something went wrong.