Move profiler imports to internal version

pg_exts_fork
Tyler Goodlet 2022-10-31 09:26:36 -04:00
parent 1d4fc6f327
commit d46945cb09
6 changed files with 18 additions and 12 deletions

View File

@ -56,6 +56,7 @@ if TYPE_CHECKING:
from .feed import maybe_open_feed from .feed import maybe_open_feed
from ..log import get_logger, get_console_log from ..log import get_logger, get_console_log
from .._profile import Profiler
log = get_logger(__name__) log = get_logger(__name__)
@ -645,7 +646,7 @@ async def tsdb_history_update(
# * the original data feed arch blurb: # * the original data feed arch blurb:
# - https://github.com/pikers/piker/issues/98 # - https://github.com/pikers/piker/issues/98
# #
profiler = pg.debug.Profiler( profiler = Profiler(
disabled=False, # not pg_profile_enabled(), disabled=False, # not pg_profile_enabled(),
delayed=False, delayed=False,
) )

View File

@ -44,6 +44,7 @@ from ._api import (
_load_builtins, _load_builtins,
_Token, _Token,
) )
from .._profile import Profiler
log = get_logger(__name__) log = get_logger(__name__)
@ -91,7 +92,7 @@ async def fsp_compute(
) -> None: ) -> None:
profiler = pg.debug.Profiler( profiler = Profiler(
delayed=False, delayed=False,
disabled=True disabled=True
) )
@ -262,7 +263,7 @@ async def cascade(
destination shm array buffer. destination shm array buffer.
''' '''
profiler = pg.debug.Profiler( profiler = Profiler(
delayed=False, delayed=False,
disabled=False disabled=False
) )

View File

@ -44,6 +44,7 @@ from ._style import hcolor
# ds_m4, # ds_m4,
# ) # )
from ..log import get_logger from ..log import get_logger
from .._profile import Profiler
log = get_logger(__name__) log = get_logger(__name__)
@ -331,7 +332,7 @@ class Curve(pg.GraphicsObject):
) -> None: ) -> None:
profiler = pg.debug.Profiler( profiler = Profiler(
msg=f'Curve.paint(): `{self._name}`', msg=f'Curve.paint(): `{self._name}`',
disabled=not pg_profile_enabled(), disabled=not pg_profile_enabled(),
ms_threshold=ms_slower_then, ms_threshold=ms_slower_then,
@ -466,7 +467,7 @@ class StepCurve(Curve):
def sub_paint( def sub_paint(
self, self,
p: QPainter, p: QPainter,
profiler: pg.debug.Profiler, profiler: Profiler,
) -> None: ) -> None:
# p.drawLines(*tuple(filter(bool, self._last_step_lines))) # p.drawLines(*tuple(filter(bool, self._last_step_lines)))

View File

@ -66,6 +66,7 @@ from .._profile import (
ms_slower_then, ms_slower_then,
) )
from ..log import get_logger from ..log import get_logger
from .._profile import Profiler
log = get_logger(__name__) log = get_logger(__name__)
@ -441,7 +442,7 @@ def graphics_update_cycle(
# TODO: just pass this as a direct ref to avoid so many attr accesses? # TODO: just pass this as a direct ref to avoid so many attr accesses?
hist_chart = ds.godwidget.hist_linked.chart hist_chart = ds.godwidget.hist_linked.chart
profiler = pg.debug.Profiler( profiler = Profiler(
msg=f'Graphics loop cycle for: `{chart.name}`', msg=f'Graphics loop cycle for: `{chart.name}`',
delayed=True, delayed=True,
disabled=not pg_profile_enabled(), disabled=not pg_profile_enabled(),

View File

@ -59,6 +59,7 @@ from ._curve import (
FlattenedOHLC, FlattenedOHLC,
) )
from ..log import get_logger from ..log import get_logger
from .._profile import Profiler
log = get_logger(__name__) log = get_logger(__name__)
@ -130,7 +131,7 @@ def render_baritems(
int, int, np.ndarray, int, int, np.ndarray,
int, int, np.ndarray, int, int, np.ndarray,
], ],
profiler: pg.debug.Profiler, profiler: Profiler,
**kwargs, **kwargs,
) -> None: ) -> None:
@ -517,7 +518,7 @@ class Flow(msgspec.Struct): # , frozen=True):
render: bool = True, render: bool = True,
array_key: Optional[str] = None, array_key: Optional[str] = None,
profiler: Optional[pg.debug.Profiler] = None, profiler: Optional[Profiler] = None,
do_append: bool = True, do_append: bool = True,
**kwargs, **kwargs,
@ -528,7 +529,7 @@ class Flow(msgspec.Struct): # , frozen=True):
render to graphics. render to graphics.
''' '''
profiler = pg.debug.Profiler( profiler = Profiler(
msg=f'Flow.update_graphics() for {self.name}', msg=f'Flow.update_graphics() for {self.name}',
disabled=not pg_profile_enabled(), disabled=not pg_profile_enabled(),
ms_threshold=4, ms_threshold=4,
@ -948,7 +949,7 @@ class Renderer(msgspec.Struct):
new_read, new_read,
array_key: str, array_key: str,
profiler: pg.debug.Profiler, profiler: Profiler,
uppx: float = 1, uppx: float = 1,
# redraw and ds flags # redraw and ds flags

View File

@ -33,6 +33,7 @@ import numpy as np
import trio import trio
from ..log import get_logger from ..log import get_logger
from .._profile import Profiler
from .._profile import pg_profile_enabled, ms_slower_then from .._profile import pg_profile_enabled, ms_slower_then
# from ._style import _min_points_to_show # from ._style import _min_points_to_show
from ._editors import SelectRect from ._editors import SelectRect
@ -779,7 +780,7 @@ class ChartView(ViewBox):
''' '''
name = self.name name = self.name
# print(f'YRANGE ON {name}') # print(f'YRANGE ON {name}')
profiler = pg.debug.Profiler( profiler = Profiler(
msg=f'`ChartView._set_yrange()`: `{name}`', msg=f'`ChartView._set_yrange()`: `{name}`',
disabled=not pg_profile_enabled(), disabled=not pg_profile_enabled(),
ms_threshold=ms_slower_then, ms_threshold=ms_slower_then,
@ -916,7 +917,7 @@ class ChartView(ViewBox):
autoscale_overlays: bool = True, autoscale_overlays: bool = True,
): ):
profiler = pg.debug.Profiler( profiler = Profiler(
msg=f'ChartView.maybe_downsample_graphics() for {self.name}', msg=f'ChartView.maybe_downsample_graphics() for {self.name}',
disabled=not pg_profile_enabled(), disabled=not pg_profile_enabled(),