Allow passing "ms slower then" value on cli to `--profile`
parent
abab8d3451
commit
9477c7e66c
|
@ -24,7 +24,7 @@ from functools import wraps
|
||||||
# NOTE: you can pass a flag to enable this:
|
# NOTE: you can pass a flag to enable this:
|
||||||
# ``piker chart <args> --profile``.
|
# ``piker chart <args> --profile``.
|
||||||
_pg_profile: bool = False
|
_pg_profile: bool = False
|
||||||
ms_slower_then: float = 10
|
ms_slower_then: float = 0
|
||||||
|
|
||||||
|
|
||||||
def pg_profile_enabled() -> bool:
|
def pg_profile_enabled() -> bool:
|
||||||
|
|
|
@ -122,7 +122,8 @@ def optschain(config, symbol, date, rate, test):
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option(
|
@click.option(
|
||||||
'--profile',
|
'--profile',
|
||||||
is_flag=True,
|
'-p',
|
||||||
|
default=None,
|
||||||
help='Enable pyqtgraph profiling'
|
help='Enable pyqtgraph profiling'
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
@ -133,9 +134,16 @@ def optschain(config, symbol, date, rate, test):
|
||||||
@click.argument('symbol', required=True)
|
@click.argument('symbol', required=True)
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def chart(config, symbol, profile, pdb):
|
def chart(config, symbol, profile, pdb):
|
||||||
"""Start a real-time chartng UI
|
'''
|
||||||
"""
|
Start a real-time chartng UI
|
||||||
|
|
||||||
|
'''
|
||||||
|
# eg. ``--profile 3`` reports profiling for anything slower then 3 ms.
|
||||||
|
if profile is not None:
|
||||||
from .. import _profile
|
from .. import _profile
|
||||||
|
_profile._pg_profile = True
|
||||||
|
_profile.ms_slower_then = float(profile)
|
||||||
|
|
||||||
from ._app import _main
|
from ._app import _main
|
||||||
|
|
||||||
if '.' not in symbol:
|
if '.' not in symbol:
|
||||||
|
@ -145,8 +153,6 @@ def chart(config, symbol, profile, pdb):
|
||||||
))
|
))
|
||||||
return
|
return
|
||||||
|
|
||||||
# toggle to enable profiling
|
|
||||||
_profile._pg_profile = profile
|
|
||||||
|
|
||||||
# global opts
|
# global opts
|
||||||
brokernames = config['brokers']
|
brokernames = config['brokers']
|
||||||
|
|
Loading…
Reference in New Issue