Don't return early on ds line render to avoid breaking profiling
The pg profiler seems to have trouble with early `return`s in function calls (likely muckery with the GC/`.__delete__()`) so let's just try to avoid it for now until we either fix it (probably by implementing as a ctx mngr) or use diff one.marketstore_backup
parent
228b2998d0
commit
f367f1a095
|
@ -265,6 +265,7 @@ class FastAppendCurve(pg.GraphicsObject):
|
|||
y_iv: np.ndarray,
|
||||
|
||||
view_range: Optional[tuple[int, int]] = None,
|
||||
profiler: Optional[pg.debug.Profiler] = None,
|
||||
|
||||
) -> QtGui.QPainterPath:
|
||||
'''
|
||||
|
@ -274,7 +275,7 @@ class FastAppendCurve(pg.GraphicsObject):
|
|||
a length diff.
|
||||
|
||||
'''
|
||||
profiler = pg.debug.Profiler(
|
||||
profiler = profiler or pg.debug.Profiler(
|
||||
msg=f'FastAppendCurve.update_from_array(): `{self._name}`',
|
||||
disabled=not pg_profile_enabled(),
|
||||
gt=ms_slower_then,
|
||||
|
|
|
@ -318,7 +318,6 @@ class BarItems(pg.GraphicsObject):
|
|||
|
||||
return self.path
|
||||
|
||||
|
||||
def x_uppx(self) -> int:
|
||||
if self._ds_line:
|
||||
return self._ds_line.x_uppx()
|
||||
|
@ -335,6 +334,7 @@ class BarItems(pg.GraphicsObject):
|
|||
ohlc_iv: np.ndarray,
|
||||
|
||||
view_range: Optional[tuple[int, int]] = None,
|
||||
profiler: Optional[pg.debug.Profiler] = None,
|
||||
|
||||
) -> None:
|
||||
'''
|
||||
|
@ -350,7 +350,7 @@ class BarItems(pg.GraphicsObject):
|
|||
This routine should be made (transitively) as fast as possible.
|
||||
|
||||
'''
|
||||
profiler = pg.debug.Profiler(
|
||||
profiler = profiler or pg.debug.Profiler(
|
||||
disabled=not pg_profile_enabled(),
|
||||
gt=ms_slower_then,
|
||||
delayed=True,
|
||||
|
@ -393,15 +393,12 @@ class BarItems(pg.GraphicsObject):
|
|||
|
||||
profiler('ds logic complete')
|
||||
|
||||
if (
|
||||
should_line
|
||||
):
|
||||
if should_line:
|
||||
# update the line graphic
|
||||
# x, y = self._ds_line_xy = ohlc_flatten(ohlc_iv)
|
||||
x, y = self._ds_line_xy = ohlc_flatten(ohlc)
|
||||
x_iv, y_iv = self._ds_line_xy = ohlc_flatten(ohlc_iv)
|
||||
profiler('flattening bars to line')
|
||||
print(f'rendering linesc')
|
||||
|
||||
# TODO: we should be diffing the amount of new data which
|
||||
# needs to be downsampled. Ideally we actually are just
|
||||
|
@ -416,6 +413,7 @@ class BarItems(pg.GraphicsObject):
|
|||
x_iv=x_iv,
|
||||
y_iv=y_iv,
|
||||
view_range=None, # hack
|
||||
profiler=profiler,
|
||||
)
|
||||
profiler('updated ds line')
|
||||
|
||||
|
@ -438,13 +436,13 @@ class BarItems(pg.GraphicsObject):
|
|||
# stop here since we don't need to update bars path any more
|
||||
# as we delegate to the downsample line with updates.
|
||||
profiler.finish()
|
||||
print('terminating early')
|
||||
# print('terminating early')
|
||||
return
|
||||
|
||||
elif (
|
||||
not should_line
|
||||
and self._in_ds
|
||||
):
|
||||
else:
|
||||
# we should be in bars mode
|
||||
|
||||
if self._in_ds:
|
||||
# flip back to bars graphics and hide the downsample line.
|
||||
log.info(f'showing bars graphic {self._name}')
|
||||
|
||||
|
@ -472,8 +470,6 @@ class BarItems(pg.GraphicsObject):
|
|||
# - maybe move all this embedded logic to a higher
|
||||
# level type?
|
||||
|
||||
# ohlc = in_view
|
||||
|
||||
# if prepend_length:
|
||||
# # new history was added and we need to render a new path
|
||||
# prepend_bars = ohlc[:prepend_length]
|
||||
|
|
Loading…
Reference in New Issue