split a method in two, some tests on callback performance

This commit is contained in:
2021-06-15 11:57:00 +02:00
parent 10b83cad9a
commit c09d14e9e4
2 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,4 @@
#from functools import partial
from random import choice from random import choice
from bokeh.layouts import column from bokeh.layouts import column
@ -28,19 +29,25 @@ class Director:
def periodic_update(self): def periodic_update(self):
for func in self.updates: for func in self.updates:
func() func()
# self.doc.add_next_tick_callback(func) #TODO: would this be an improvement?
def do_add_pvs(self, attr, old, new): def do_add_pvs(self, attr, old, new):
if not new: return # do not trigger on the following value reset if not new: return # do not trigger on the following value reset
self.sp_add_pvs.value = "" self.sp_add_pvs.value = ""
print(f"CB Add PV: attribute \"{attr}\" changed from \"{old}\" to \"{new}\"") print(f"CB Add PV: attribute \"{attr}\" changed from \"{old}\" to \"{new}\"")
self.add_pvs(new)
# self.doc.add_next_tick_callback(partial(self.add_pvs, new)) #TODO: would this be an improvement?
def add_pvs(self, new):
new = new.upper() # PV names are all upper case new = new.upper() # PV names are all upper case
grid = break_apart(new) grid = break_apart(new)
print(normalized_string(grid)) print(normalized_string(grid))
self.add_pvs(grid) self.add_pvs_grid(grid)
def add_pvs(self, pvnames_grid): def add_pvs_grid(self, pvnames_grid):
for pvnames in reversed(pvnames_grid): for pvnames in reversed(pvnames_grid):
pvs_row = self.make_pvs_row(pvnames) pvs_row = self.make_pvs_row(pvnames)
if not pvs_row.children: if not pvs_row.children:

View File

@ -4,7 +4,7 @@ from kabuki.director import Director
app = Director() app = Director()
app.doc.add_periodic_callback(print_caches, 10000) app.doc.add_periodic_callback(print_caches, 10000)
app.add_pvs([["MTEST:RAND0"], ["MTEST:ARR", "MTEST:CHAN-IMAGE:FPICTURE"]]) app.add_pvs_grid([["MTEST:RAND0"], ["MTEST:ARR", "MTEST:CHAN-IMAGE:FPICTURE"]])