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,
|
y_iv: np.ndarray,
|
||||||
|
|
||||||
view_range: Optional[tuple[int, int]] = None,
|
view_range: Optional[tuple[int, int]] = None,
|
||||||
|
profiler: Optional[pg.debug.Profiler] = None,
|
||||||
|
|
||||||
) -> QtGui.QPainterPath:
|
) -> QtGui.QPainterPath:
|
||||||
'''
|
'''
|
||||||
|
@ -274,7 +275,7 @@ class FastAppendCurve(pg.GraphicsObject):
|
||||||
a length diff.
|
a length diff.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
profiler = pg.debug.Profiler(
|
profiler = profiler or pg.debug.Profiler(
|
||||||
msg=f'FastAppendCurve.update_from_array(): `{self._name}`',
|
msg=f'FastAppendCurve.update_from_array(): `{self._name}`',
|
||||||
disabled=not pg_profile_enabled(),
|
disabled=not pg_profile_enabled(),
|
||||||
gt=ms_slower_then,
|
gt=ms_slower_then,
|
||||||
|
|
|
@ -318,7 +318,6 @@ class BarItems(pg.GraphicsObject):
|
||||||
|
|
||||||
return self.path
|
return self.path
|
||||||
|
|
||||||
|
|
||||||
def x_uppx(self) -> int:
|
def x_uppx(self) -> int:
|
||||||
if self._ds_line:
|
if self._ds_line:
|
||||||
return self._ds_line.x_uppx()
|
return self._ds_line.x_uppx()
|
||||||
|
@ -335,6 +334,7 @@ class BarItems(pg.GraphicsObject):
|
||||||
ohlc_iv: np.ndarray,
|
ohlc_iv: np.ndarray,
|
||||||
|
|
||||||
view_range: Optional[tuple[int, int]] = None,
|
view_range: Optional[tuple[int, int]] = None,
|
||||||
|
profiler: Optional[pg.debug.Profiler] = None,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
|
@ -350,7 +350,7 @@ class BarItems(pg.GraphicsObject):
|
||||||
This routine should be made (transitively) as fast as possible.
|
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(),
|
disabled=not pg_profile_enabled(),
|
||||||
gt=ms_slower_then,
|
gt=ms_slower_then,
|
||||||
delayed=True,
|
delayed=True,
|
||||||
|
@ -393,15 +393,12 @@ class BarItems(pg.GraphicsObject):
|
||||||
|
|
||||||
profiler('ds logic complete')
|
profiler('ds logic complete')
|
||||||
|
|
||||||
if (
|
if should_line:
|
||||||
should_line
|
|
||||||
):
|
|
||||||
# update the line graphic
|
# update the line graphic
|
||||||
# x, y = self._ds_line_xy = ohlc_flatten(ohlc_iv)
|
# x, y = self._ds_line_xy = ohlc_flatten(ohlc_iv)
|
||||||
x, y = self._ds_line_xy = ohlc_flatten(ohlc)
|
x, y = self._ds_line_xy = ohlc_flatten(ohlc)
|
||||||
x_iv, y_iv = self._ds_line_xy = ohlc_flatten(ohlc_iv)
|
x_iv, y_iv = self._ds_line_xy = ohlc_flatten(ohlc_iv)
|
||||||
profiler('flattening bars to line')
|
profiler('flattening bars to line')
|
||||||
print(f'rendering linesc')
|
|
||||||
|
|
||||||
# TODO: we should be diffing the amount of new data which
|
# TODO: we should be diffing the amount of new data which
|
||||||
# needs to be downsampled. Ideally we actually are just
|
# needs to be downsampled. Ideally we actually are just
|
||||||
|
@ -416,6 +413,7 @@ class BarItems(pg.GraphicsObject):
|
||||||
x_iv=x_iv,
|
x_iv=x_iv,
|
||||||
y_iv=y_iv,
|
y_iv=y_iv,
|
||||||
view_range=None, # hack
|
view_range=None, # hack
|
||||||
|
profiler=profiler,
|
||||||
)
|
)
|
||||||
profiler('updated ds line')
|
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
|
# stop here since we don't need to update bars path any more
|
||||||
# as we delegate to the downsample line with updates.
|
# as we delegate to the downsample line with updates.
|
||||||
profiler.finish()
|
profiler.finish()
|
||||||
print('terminating early')
|
# print('terminating early')
|
||||||
return
|
return
|
||||||
|
|
||||||
elif (
|
else:
|
||||||
not should_line
|
# we should be in bars mode
|
||||||
and self._in_ds
|
|
||||||
):
|
if self._in_ds:
|
||||||
# flip back to bars graphics and hide the downsample line.
|
# flip back to bars graphics and hide the downsample line.
|
||||||
log.info(f'showing bars graphic {self._name}')
|
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
|
# - maybe move all this embedded logic to a higher
|
||||||
# level type?
|
# level type?
|
||||||
|
|
||||||
# ohlc = in_view
|
|
||||||
|
|
||||||
# if prepend_length:
|
# if prepend_length:
|
||||||
# # new history was added and we need to render a new path
|
# # new history was added and we need to render a new path
|
||||||
# prepend_bars = ohlc[:prepend_length]
|
# prepend_bars = ohlc[:prepend_length]
|
||||||
|
|
Loading…
Reference in New Issue