-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Easier entry point using bench commands
Use `bench --site sitename run-microbenchmarks` to run all benchmarks. Use `--filter=substring` to filter benchmarks. There are no other custom flags, rest are inherited from `pyperf`. Use `bench --site sitename run-microbenchmarks --help` or refer to https://pyperf.readthedocs.io/
- Loading branch information
Showing
2 changed files
with
33 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import subprocess | ||
|
||
import click | ||
from frappe.commands import pass_context | ||
from frappe.exceptions import SiteNotSpecifiedError | ||
|
||
|
||
@click.command( | ||
"run-microbenchmarks", | ||
context_settings=dict( | ||
ignore_unknown_options=True, | ||
), | ||
add_help_option=False, | ||
) | ||
@click.argument("benchargs", nargs=-1, type=click.UNPROCESSED) | ||
@pass_context | ||
def run_benchmarks(ctx, benchargs): | ||
if not ctx.sites: | ||
raise SiteNotSpecifiedError | ||
site = ctx.sites[0] | ||
benchargs = ("--site", site) + benchargs | ||
|
||
from caffeine.microbenchmarks import run_benchmarks | ||
|
||
# XXX: We can't invoke it directly pyperf wants to be the entry point | ||
# Anyway, this shouldn't be a problem. It's no different than shell invoking it. | ||
subprocess.check_call(["../env/bin/python3", run_benchmarks.__file__, *benchargs]) | ||
|
||
|
||
commands = [ | ||
run_benchmarks, | ||
] |