Drop `index_field` input to renders, add `.read()` profiling

multichartz
Tyler Goodlet 2022-12-02 20:05:49 -05:00
parent 363820ddc0
commit 3da84387c3
1 changed files with 23 additions and 9 deletions

View File

@ -44,10 +44,6 @@ from ..data._formatters import (
StepCurveFmtr, # "step" curve (like for vlm) StepCurveFmtr, # "step" curve (like for vlm)
) )
from ..data._pathops import xy_downsample from ..data._pathops import xy_downsample
from .._profile import (
pg_profile_enabled,
# ms_slower_then,
)
from ._ohlc import ( from ._ohlc import (
BarItems, BarItems,
# bar_from_ohlc_row, # bar_from_ohlc_row,
@ -58,7 +54,10 @@ from ._curve import (
FlattenedOHLC, FlattenedOHLC,
) )
from ..log import get_logger from ..log import get_logger
from .._profile import Profiler from .._profile import (
Profiler,
pg_profile_enabled,
)
log = get_logger(__name__) log = get_logger(__name__)
@ -102,7 +101,7 @@ def render_baritems(
fmtr=OHLCBarsFmtr( fmtr=OHLCBarsFmtr(
shm=viz.shm, shm=viz.shm,
viz=viz, viz=viz,
index_field=viz.index_field, # index_field=viz.index_field,
), ),
) )
@ -111,7 +110,7 @@ def render_baritems(
fmtr=OHLCBarsAsCurveFmtr( fmtr=OHLCBarsAsCurveFmtr(
shm=viz.shm, shm=viz.shm,
viz=viz, viz=viz,
index_field=viz.index_field, # index_field=viz.index_field,
), ),
) )
@ -192,6 +191,7 @@ def render_baritems(
curve.hide() curve.hide()
bars.show() bars.show()
bars.update() bars.update()
# breakpoint()
return ( return (
graphics, graphics,
@ -401,6 +401,7 @@ class Viz(msgspec.Struct): # , frozen=True):
self, self,
array_field: Optional[str] = None, array_field: Optional[str] = None,
index_field: str | None = None, index_field: str | None = None,
profiler: None | Profiler = None,
) -> tuple[ ) -> tuple[
int, int, np.ndarray, int, int, np.ndarray,
@ -418,6 +419,9 @@ class Viz(msgspec.Struct): # , frozen=True):
# readable data # readable data
array = self.shm.array array = self.shm.array
if profiler:
profiler('self.shm.array READ')
( (
ifirst, ifirst,
l, l,
@ -429,6 +433,9 @@ class Viz(msgspec.Struct): # , frozen=True):
# if rbar < lbar: # if rbar < lbar:
# breakpoint() # breakpoint()
if profiler:
profiler('self.datums_range()')
abs_slc = slice(ifirst, ilast) abs_slc = slice(ifirst, ilast)
# TODO: support time slicing # TODO: support time slicing
@ -454,6 +461,12 @@ class Viz(msgspec.Struct): # , frozen=True):
# f'start/stop: {lbar},{rbar}\n', # f'start/stop: {lbar},{rbar}\n',
# f'diff: {diff}\n', # f'diff: {diff}\n',
# ) # )
if profiler:
profiler(
'`Flume.slice_from_time('
f'start_t={lbar}'
f'stop_t={rbar})'
)
# array-index slicing # array-index slicing
# TODO: can we do time based indexing using arithmetic presuming # TODO: can we do time based indexing using arithmetic presuming
@ -470,6 +483,8 @@ class Viz(msgspec.Struct): # , frozen=True):
# XXX: same as ^ # XXX: same as ^
# to_draw = array[lbar - ifirst:(rbar - ifirst) + 1] # to_draw = array[lbar - ifirst:(rbar - ifirst) + 1]
if profiler:
profiler('index arithmetic for slicing')
if array_field: if array_field:
array = array[array_field] array = array[array_field]
@ -513,7 +528,7 @@ class Viz(msgspec.Struct): # , frozen=True):
read = ( read = (
xfirst, xlast, src_array, xfirst, xlast, src_array,
ivl, ivr, in_view, ivl, ivr, in_view,
) = self.read() ) = self.read(profiler=profiler)
profiler('read src shm data') profiler('read src shm data')
@ -562,7 +577,6 @@ class Viz(msgspec.Struct): # , frozen=True):
fmtr=StepCurveFmtr( fmtr=StepCurveFmtr(
shm=self.shm, shm=self.shm,
viz=self, viz=self,
index_field=self.index_field,
), ),
) )