Super-Fluid / heqet

Organize Euterpea music for real instruments and create scores with Lilypond
GNU General Public License v3.0
3 stars 3 forks source link

performance!!! #126

Open Super-Fluid opened 8 years ago

Super-Fluid commented 8 years ago

yeah, I guess I need to use better algorithms.

Even with no chronological invariant, sorting and then using a linear algorithm is still O(log n) time rather than my current O(n^2) everywhere. Making it an invariant would add a cost to parI but give linear time many places. The danger is that adding together lots of small bits of music would then be expensive. need a parIMap maybe, like concatMap.

Oh and what about using a better data structure for the music...hm, maybe a sort of vector in InTimes?

and Text rather than strings

Super-Fluid commented 8 years ago

What if you had a tree of lists (and start/stop times for each list) — if you need to go through all the notes in chronological order, then the tree would flatten to a single list, but if you only need a part, then only that part would be flattened, and some operations would not require flattening at all, like mapping over every note without order.

Also, there might be an advantage to collecting many operations in the data structure and forcing them all at once, allowing a more efficient algorithm. Like instead of a merge sort of 100 pieces, put them all in a list and sort once. Actually that might not be a good example.

data Music = MList [Music] | MNote LyNote

Super-Fluid commented 8 years ago

I mean O(n log n) not O(log n)