Mercurial > code > home > repos > light9
changeset 1774:74ec008aee56
big sequencer speedup: only rebuild notes in the changed song
Ignore-this: 7d4f16423727daa90eb61518a41f57d3
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sun, 03 Jun 2018 11:35:06 +0000 |
parents | 2fe4bb539b52 |
children | 64db0e6b2be9 |
files | light9/effect/sequencer.py |
diffstat | 1 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/effect/sequencer.py Sun Jun 03 11:31:21 2018 +0000 +++ b/light9/effect/sequencer.py Sun Jun 03 11:35:06 2018 +0000 @@ -26,7 +26,8 @@ log = logging.getLogger('sequencer') stats = scales.collection('/sequencer/', scales.PmfStat('update'), - scales.PmfStat('compile'), + scales.PmfStat('compileGraph'), + scales.PmfStat('compileSong'), scales.DoubleStat('recentFps'), ) @@ -164,7 +165,7 @@ class Sequencer(object): def __init__(self, graph, sendToCollector, fps=30): self.graph = graph - self.fps = 30 + self.fps = 60 self.sendToCollector = sendToCollector self.music = MusicTime(period=.2, pollCurvecalc=False) @@ -179,21 +180,27 @@ self.codeWatcher = CodeWatcher( onChange=lambda: self.graph.addHandler(self.compileGraph)) - @stats.compile.time() + @stats.compileGraph.time() def compileGraph(self): """rebuild our data from the graph""" - log.info('compileGraph start') t1 = time.time() g = self.graph for song in g.subjects(RDF.type, L9['Song']): - # ideally, wrap this (or smaller) in a sub-handler to run less on each patch - self.notes[song] = [] - for note in g.objects(song, L9['note']): - self.notes[song].append(Note(g, note, effecteval, - self.simpleOutputs)) - log.info('compileGraph done %.2f ms', 1000 * (time.time() - t1)) + self.graph.addHandler(lambda song=song: self.compileSong(song)) + log.info('compileGraph took %.2f ms', 1000 * (time.time() - t1)) + + @stats.compileSong.time() + def compileSong(self, song): + t1 = time.time() + self.notes[song] = [] + for note in self.graph.objects(song, L9['note']): + self.notes[song].append(Note(self.graph, note, effecteval, + self.simpleOutputs)) + log.info(' compile %s took %.2f ms', song, 1000 * (time.time() - t1)) + + @stats.update.time() def update(self): now = time.time()