-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: migrate smaller benchmarks to
NanoBenchmark
- Loading branch information
Showing
5 changed files
with
49 additions
and
36 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,41 +1,48 @@ | ||
import textwrap | ||
|
||
import frappe | ||
|
||
from caffeine.microbenchmarks.utils import NanoBenchmark | ||
|
||
def bench_qb_select_star(): | ||
table = frappe.qb.DocType("Role") | ||
return frappe.qb.from_(table).select("*").limit(20).run(run=0) | ||
bench_qb_select_star = NanoBenchmark( | ||
'frappe.qb.from_(table).select("*").limit(20).run(run=0)', | ||
setup='table = frappe.qb.DocType("Role")', | ||
) | ||
|
||
|
||
def bench_qb_select_star_multiple_fields(): | ||
table = frappe.qb.DocType("Role") | ||
return frappe.qb.from_(table).select(table.name, table.creation, table.modified).limit(20).run(run=0) | ||
bench_qb_select_multiple_fields = NanoBenchmark( | ||
"frappe.qb.from_(table).select(table.name, table.creation, table.modified).limit(20).run(run=0)", | ||
setup='table = frappe.qb.DocType("Role")', | ||
) | ||
|
||
|
||
def bench_qb_get_query(): | ||
return frappe.qb.get_query( | ||
bench_qb_get_query = NanoBenchmark( | ||
"""frappe.qb.get_query( | ||
"Role", | ||
filters={"creation": (">", "2020-01-01 00:00:00")}, | ||
fields="disabled", | ||
limit=10, | ||
order_by="creation asc", | ||
).run(run=0) | ||
|
||
).run(run=0)""" | ||
) | ||
|
||
def bench_qb_get_query_multiple_fields(): | ||
return frappe.qb.get_query( | ||
bench_qb_get_query_multiple_fields = NanoBenchmark( | ||
"""frappe.qb.get_query( | ||
"Role", | ||
filters={"creation": (">", "2020-01-01 00:00:00")}, | ||
fields=["disabled", "name", "creation", "modified"], | ||
limit=10, | ||
order_by="creation asc", | ||
).run(run=0) | ||
|
||
|
||
def bench_qb_simple_get_query(): | ||
return frappe.qb.get_query( | ||
"Role", | ||
filters={"name": "Guest"}, | ||
fields="*", | ||
limit=1, | ||
order_by="creation asc", | ||
).run(run=0) | ||
).run(run=0)""" | ||
) | ||
|
||
|
||
bench_qb_simple_get_query = NanoBenchmark( | ||
"""frappe.qb.get_query( | ||
"Role", | ||
filters={"name": "Guest"}, | ||
fields="*", | ||
limit=1, | ||
order_by="creation asc", | ||
).run(run=0)""" | ||
) |
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